/* ============================================================
   שליחים · BBB נתניה — ערכת נושא בהירה, מובייל ראשון, RTL
   צבעי המותג נדגמו מהלוגו של BBB נתניה:
   סגול #563D5D · אדום #EF492F · ירוק #8BBD68
   כל שמות המחלקות זהים לגרסה הקודמת — רק הצבעים והמשטחים השתנו.
   ============================================================ */

:root {
  /* מותג */
  --purple:      #563D5D;
  --purple-600:  #6B4A75;
  --purple-300:  #9B7BA6;
  --purple-50:   #F6F2F8;
  --brand-red:   #EF492F;
  --brand-green: #8BBD68;

  /* משטחים */
  --ink:        #F7F5F9;   /* רקע הדף */
  --ink-2:      #FBFAFC;   /* רקע שדות */
  --surface:    #FFFFFF;   /* כרטיס */
  --surface-2:  #FFFFFF;   /* כפתור רגיל */
  --surface-3:  #F1ECF4;   /* משטח מודגש */
  --line:       rgba(86, 61, 93, .11);
  --line-str:   rgba(86, 61, 93, .22);

  /* טקסט — כל הגוונים עוברים AA על לבן */
  --txt:        #241E29;
  --muted:      #5F566A;
  --muted-2:    #756B80;

  /* מצבים */
  --gold:       #B36A00;
  --gold-soft:  rgba(240, 169, 59, .17);
  --ember:      #EF492F;
  --red:        #C2321B;
  --red-soft:   rgba(239, 73, 47, .10);
  --green:      #3F7A2E;
  --green-soft: rgba(139, 189, 104, .20);
  --blue:       #2E5FA3;
  --blue-soft:  rgba(46, 95, 163, .10);

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --shadow:     0 1px 2px rgba(32, 22, 40, .05), 0 10px 24px -18px rgba(32, 22, 40, .30);
  --shadow-lg:  0 2px 6px rgba(32, 22, 40, .06), 0 26px 50px -26px rgba(32, 22, 40, .38);
  --shadow-brand: 0 12px 28px -14px rgba(86, 61, 93, .55);
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--txt);
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* זוהר המותג — אותו רקע כמו בשאר מערכות BBB */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(55% 45% at 92% -5%,  rgba(86, 61, 93, .13), transparent 70%),
    radial-gradient(40% 35% at 4% 8%,    rgba(239, 73, 47, .07), transparent 70%),
    radial-gradient(45% 40% at 60% 105%, rgba(139, 189, 104, .10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; }
a { color: var(--purple); }

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

.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; text-align: right; }

/* ---------------- כניסה ---------------- */

.login-body { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-wrap { width: 100%; max-width: 420px; position: relative; z-index: 1; }

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 26px 22px 22px;
  box-shadow: var(--shadow-lg);
}

.brand { display: grid; justify-items: center; gap: 6px; margin-bottom: 22px; text-align: center; }
.brand-mark {
  display: grid; place-items: center;
  padding: 4px 6px;
}
.brand-logo { display: block; width: 194px; max-width: 62%; height: auto; }
.brand h1 { margin: 8px 0 0; font-size: 21px; font-weight: 800; letter-spacing: -.4px; color: var(--purple); }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; font-weight: 500; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--purple-50); border: 1px solid var(--line);
  padding: 4px; border-radius: 14px; margin-bottom: 18px;
}
.tab {
  min-height: var(--tap); border: 0; border-radius: 11px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 15px; transition: .18s;
}
.tab.is-active { background: #fff; color: var(--purple); box-shadow: 0 2px 8px rgba(86,61,93,.14); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: var(--tap);
  background: var(--ink-2); border: 1px solid var(--line-str);
  border-radius: 12px; padding: 10px 13px; color: var(--txt);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px rgba(86,61,93,.12);
}
.field input[disabled], .field select[disabled] { background: var(--surface-3); color: var(--muted); }
.pin-input { text-align: center; letter-spacing: 12px; font-size: 24px; font-weight: 700; }

.hint { color: var(--muted-2); font-size: 12.5px; line-height: 1.6; margin: -4px 0 14px; }

.btn {
  min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line-str);
  background: var(--surface-2); color: var(--txt); font-weight: 600; font-size: 15px;
  padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .12s, filter .15s, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--purple-50); }
.btn:active { transform: scale(.975); }
.btn-lg { width: 100%; font-size: 16.5px; min-height: 52px; }
.btn-sm { min-height: var(--tap); font-size: 13.5px; padding: 0 12px; border-radius: 10px; }
.btn-primary {
  background: var(--purple); color: #fff; border-color: transparent; font-weight: 800;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--purple-600); }
.btn-danger { background: var(--red-soft); border-color: rgba(239,73,47,.35); color: var(--red); font-weight: 700; }
.btn-danger:hover { background: rgba(239,73,47,.16); }
.btn-good { background: var(--green-soft); border-color: rgba(139,189,104,.5); color: var(--green); font-weight: 700; }
.btn-good:hover { background: rgba(139,189,104,.3); }
.btn-ghost { background: transparent; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.alert { border-radius: 12px; padding: 11px 13px; font-size: 14px; margin-bottom: 14px; font-weight: 500; }
.alert-error { background: var(--red-soft); border: 1px solid rgba(239,73,47,.35); color: var(--red); }
.alert-warn  { background: var(--gold-soft); border: 1px solid rgba(240,169,59,.45); color: #8A5200; }
.alert-info  { background: var(--purple-50); border: 1px solid var(--line-str); color: var(--purple); }
.alert-ok    { background: var(--green-soft); border: 1px solid rgba(139,189,104,.5); color: var(--green); }

.login-foot, .app-foot {
  text-align: center; color: var(--muted-2); font-size: 11.5px;
  margin: 18px 0 4px; padding: 0 12px;
}

/* ---------------- מעטפת האפליקציה ---------------- */

.app-body { padding-bottom: calc(84px + var(--safe-b)); }
#app { position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { height: 30px; width: auto; display: block; }
.topbar-title { font-weight: 800; font-size: 16px; line-height: 1.1; color: var(--purple); }
.topbar-sub { color: var(--muted); font-size: 11.5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 13px; font-weight: 500; }
.inline { display: inline; }

.view { max-width: 1120px; margin: 0 auto; padding: 14px 14px 8px; }

/* ---------------- כרטיסים וסקציות ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 500; }

.section-title {
  font-size: 12.5px; color: var(--purple);
  font-weight: 800; margin: 18px 2px 8px;
}

/* קוביות סיכום */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 12px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 21px; font-weight: 800; letter-spacing: -.5px; }
.stat span { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.stat.good b { color: var(--green); }
.stat.bad b  { color: var(--red); }
.stat.warn b { color: var(--gold); }
.stat.info b { color: var(--blue); }

/* ---------------- טופס הזנה מהיר ---------------- */

.quick { border: 1px solid rgba(86,61,93,.22); background: linear-gradient(180deg, var(--purple-50), #fff 60%); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (min-width: 720px) {
  .quick .grid2 { grid-template-columns: repeat(4, 1fr); }
}
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--purple-50); border: 1px solid var(--line-str); border-radius: 12px; padding: 4px; }
.seg.seg3 { grid-template-columns: 1fr 1fr 1fr; }
.seg.seg4 { grid-template-columns: repeat(4, 1fr); }
.seg button {
  min-height: var(--tap); border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 14px; transition: .15s;
}
.seg button.on { background: #fff; color: var(--purple); box-shadow: 0 2px 8px rgba(86,61,93,.14); }
.seg button.on[data-v="cash"]  { background: var(--green-soft); color: var(--green); }
.seg button.on[data-v="other"] { background: var(--blue-soft); color: var(--blue); }
.seg button[disabled] { opacity: .45; pointer-events: none; }

.check-row { display: flex; align-items: center; gap: 9px; min-height: var(--tap); }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--purple); flex: none; }
.check-row label { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ---------------- רשימת משלוחים ---------------- */

.dlv {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: 11px;
  padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 8px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.dlv.is-debt { border-color: rgba(239,73,47,.35); background: linear-gradient(90deg, rgba(239,73,47,.06), #fff 60%); }
.dlv.is-out  { border-color: rgba(240,169,59,.5); }
.dlv.is-late { border-color: rgba(239,73,47,.5); box-shadow: inset 3px 0 0 var(--ember), var(--shadow); }
.dlv.is-void { opacity: .55; }
.dlv-no {
  min-width: 52px; text-align: center; padding: 6px 8px; border-radius: 10px;
  background: var(--purple-50); color: var(--purple); font-weight: 800; font-size: 15px;
}
.dlv-main { min-width: 0; }
.dlv-line1 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 600; font-size: 14.5px; }
.dlv-line2 { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.dlv-amt { text-align: left; font-weight: 800; font-size: 16px; white-space: nowrap; }
.dlv-amt small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.dlv-actions { display: flex; gap: 6px; margin-top: 9px; grid-column: 1 / -1; flex-wrap: wrap; }

.pill {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
}
.pill.cash    { background: var(--green-soft); color: var(--green); }
.pill.other   { background: var(--blue-soft); color: var(--blue); }
.pill.out     { background: var(--gold-soft); color: #8A5200; }
.pill.debt    { background: var(--red-soft); color: var(--red); }
.pill.paid    { background: var(--surface-3); color: var(--muted); }
.pill.void    { background: var(--surface-3); color: var(--muted-2); text-decoration: line-through; }
.pill.brand   { background: var(--purple-50); color: var(--purple); }
.pill.company { background: var(--purple-50); color: var(--purple-600); }
.pill.shift   { background: var(--purple-50); color: var(--purple); }
.pill.role    { background: var(--purple-50); color: var(--purple); }
.pill.late     { background: var(--red-soft); color: var(--red); }
.pill.credit   { background: var(--gold-soft); color: #8A5200; }
.pill.delay    { background: var(--gold-soft); color: #8A5200; }
.pill.issue,
.pill.incident { background: var(--red-soft); color: var(--red); }
.pill.ok       { background: var(--green-soft); color: var(--green); }

/* הפרש מוכן→יצא */
.gap-badge {
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
}
.gap-badge.warn { background: var(--gold-soft); color: #8A5200; }
.gap-badge.late,
.gap-badge.bad  { background: var(--red-soft); color: var(--red); }

/* מתג גבייה */
.collect {
  min-width: 46px; min-height: 46px; border-radius: 13px;
  border: 1px solid var(--line-str); background: #fff;
  display: grid; place-items: center; font-size: 20px; line-height: 1;
  color: var(--muted); transition: .15s;
}
.collect.on { background: var(--green-soft); border-color: rgba(139,189,104,.7); color: var(--green); }
.collect.locked { opacity: .55; }

/* ---------------- כרטיס שליח ---------------- */

.drv-grid { display: grid; gap: 10px; }
@media (min-width: 760px) { .drv-grid { grid-template-columns: 1fr 1fr; } }

.drv {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 13px;
  box-shadow: var(--shadow);
}
.drv.has-debt { border-color: rgba(239,73,47,.35); box-shadow: inset 0 0 0 1px rgba(239,73,47,.07), var(--shadow); }
.drv-top { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.avatar {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--purple-50); color: var(--purple); font-weight: 800; font-size: 16px;
  border: 1px solid rgba(86,61,93,.2); flex: none;
}
.drv-name { font-weight: 700; font-size: 15.5px; }
.drv-meta { color: var(--muted); font-size: 12px; }
.drv-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; text-align: center; }
.drv-nums div { background: var(--ink-2); border: 1px solid var(--line); border-radius: 11px; padding: 8px 4px; }
.drv-nums b { display: block; font-size: 15px; font-weight: 800; }
.drv-nums span { font-size: 10.5px; color: var(--muted); }
.drv-foot { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }

/* ---------------- משמרת פתוחה ---------------- */

.shift-bar, .shiftbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 13px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
}
.shift-bar.is-open, .shiftbar.is-open { border-color: rgba(139,189,104,.6); background: linear-gradient(90deg, var(--green-soft), #fff 55%); }
.shift-bar.is-closed, .shiftbar.is-closed { border-color: var(--line-str); }
.shift-bar-main, .shiftbar-main { flex: 1; min-width: 0; }
.shift-bar-title, .shiftbar-title { font-weight: 800; font-size: 15px; }
.shift-bar-meta, .shiftbar-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.shift-bar .btn, .shiftbar .btn { flex: none; }

/* ---------------- הרשאות ---------------- */

.perm-grid { display: grid; gap: 6px; margin-top: 6px; }
.perm-row {
  display: flex; align-items: center; gap: 9px; min-height: var(--tap);
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--ink-2);
}
.perm-row input[type=checkbox] { width: 21px; height: 21px; accent-color: var(--purple); flex: none; }
.perm-row label { font-size: 13.5px; font-weight: 500; cursor: pointer; }
.perm-row.is-locked { opacity: .6; }

/* ---------------- טבלאות ---------------- */

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.tbl th, table.tbl td { padding: 9px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { color: var(--muted); font-weight: 700; font-size: 12px; position: sticky; top: 0; background: var(--purple-50); }
table.tbl tbody tr:hover { background: var(--purple-50); }
table.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--line-str); border-bottom: 0; }
.t-red { color: var(--red); font-weight: 700; }
.t-green { color: var(--green); font-weight: 700; }
.t-muted { color: var(--muted); }

/* ---------------- ניווט תחתון ---------------- */

.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px -18px rgba(32, 22, 40, .5);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.tabbtn {
  border: 0; background: transparent; color: var(--muted-2);
  min-height: var(--tap); border-radius: 12px;
  display: grid; place-items: center; gap: 1px;
  font-size: 11px; font-weight: 600; transition: .15s;
}
.tabbtn .ico { font-size: 19px; line-height: 1.1; filter: grayscale(.55) opacity(.75); }
.tabbtn.is-active { color: var(--purple); background: var(--purple-50); font-weight: 800; }
.tabbtn.is-active .ico { filter: none; }

/* ---------------- טוסט + מודאל ---------------- */

.toast {
  position: fixed; bottom: calc(92px + var(--safe-b)); inset-inline: 0;
  margin: 0 auto; width: max-content; max-width: 92vw;
  background: #2E2536; border: 1px solid rgba(0,0,0,.2);
  color: #fff; padding: 11px 16px; border-radius: 13px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: .22s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #8E1F0C; border-color: rgba(239,73,47,.5); color: #fff; }
.toast.ok  { background: #2F6023; border-color: rgba(139,189,104,.5); color: #fff; }

.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(36, 30, 41, .5); backdrop-filter: blur(4px);
  display: grid; place-items: end center; padding: 0;
}
.modal-card {
  width: 100%; max-width: 520px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  animation: rise .22s ease;
  max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal { place-items: center; padding: 20px; }
  .modal-card { border-radius: 22px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }

.empty {
  text-align: center; color: var(--muted-2); padding: 26px 14px;
  border: 1px dashed var(--line-str); border-radius: var(--r); font-size: 14px;
  background: rgba(255,255,255,.6);
}
.empty .big { font-size: 30px; display: block; margin-bottom: 6px; opacity: .75; }

.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.daybar select, .daybar input[type=date] {
  min-height: var(--tap); background: #fff; border: 1px solid var(--line-str);
  border-radius: 12px; padding: 0 12px; color: var(--txt); flex: 1;
}
.badge-demo {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold-soft); border: 1px dashed rgba(240,169,59,.55);
  color: #8A5200; font-size: 12px; font-weight: 600;
  padding: 7px 11px; border-radius: 11px; margin-bottom: 12px; width: 100%;
}

.list-note { color: var(--muted); font-size: 12.5px; margin: 4px 2px 10px; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(86,61,93,.25); border-top-color: var(--purple); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---------------- הדפסה ---------------- */

@media print {
  body::before, .topbar, .tabbar, .toast, .modal, .app-foot, .no-print { display: none !important; }
  html, body { background: #fff; color: #000; }
  .card, .drv, .stat, .dlv { background: #fff; border-color: #ccc; box-shadow: none; }
  table.tbl th { background: #eee; color: #000; }
  table.tbl th, table.tbl td { border-bottom: 1px solid #bbb; }
  .t-red { color: #b00; }
}
