/* ===== טוקנים – ערכת בהיר ===== */
:root {
  --bg: #f1f4fa;
  --surface: #ffffff;
  --surface-head: #e7ecf7;
  --surface-row: #f5f8fd;
  --surface-sunken: #fbfcff;
  --input-bg: rgba(255, 255, 255, .78);
  --ink: #1d2733;
  --muted: #66748a;
  --line: #dfe4ef;
  --brand: #2f5fe0;
  --brand-dark: #23499f;
  --brand-ink: #ffffff;
  --closed-a: #f4f5f9;
  --closed-b: #eaecf3;

  --morning: #fbeecb;
  --morning-line: #d99f22;
  --middle: #d6f0e4;
  --middle-line: #2c9770;
  --evening: #dde5fa;
  --evening-line: #4763c9;

  --c0-bg: #fbeecb; --c0-line: #d99f22;
  --c1-bg: #d6f0e4; --c1-line: #2c9770;
  --c2-bg: #dde5fa; --c2-line: #4763c9;
  --c3-bg: #e9ddf7; --c3-line: #8250c4;
  --c4-bg: #fbdde8; --c4-line: #c94a7d;
  --c5-bg: #d3f0f2; --c5-line: #1f8f9c;
  --c6-bg: #e6e9ef; --c6-line: #6b7688;
  --c7-bg: #f0e3d4; --c7-line: #a1713a;

  --err: #bc2f47;
  --err-bg: #fdecef;
  --err-line: #f0bcc7;
  --warn: #8a5a00;
  --warn-bg: #fff5e0;
  --warn-line: #efd8a4;
  --info: #26647f;
  --info-bg: #e9f3f9;
  --info-line: #c9e1ee;
  --ok: #1a7048;
  --ok-bg: #e6f5ec;
  --ok-line: #b2dfc4;
  --badge-warn: #d9941f;
  --off-day: #48546a;

  --header-from: #23499f;
  --header-to: #2f5fe0;
  --header-ink: #ffffff;
  --toast-bg: #1d2733;
  --toast-ink: #ffffff;
  --shadow: 0 2px 12px rgba(29, 39, 51, .12);
  --shadow-lg: 0 6px 20px rgba(29, 39, 51, .28);
}

/* ===== ערכה כהה – לפי העדפת המערכת ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131722;
    --surface: #1b2130;
    --surface-head: #232b3d;
    --surface-row: #202736;
    --surface-sunken: #1f2635;
    --input-bg: rgba(255, 255, 255, .06);
    --ink: #e6eaf2;
    --muted: #97a3b8;
    --line: #313a4e;
    --brand: #6d91f0;
    --brand-dark: #4d72d8;
    --brand-ink: #10141d;
    --closed-a: #1a202d;
    --closed-b: #222a3a;

    --morning: #4a3a14;
    --morning-line: #d99f22;
    --middle: #123a2c;
    --middle-line: #35b184;
    --evening: #1f2b50;
    --evening-line: #7590e8;

    --c0-bg: #4a3a14; --c0-line: #d99f22;
    --c1-bg: #123a2c; --c1-line: #35b184;
    --c2-bg: #1f2b50; --c2-line: #7590e8;
    --c3-bg: #33224d; --c3-line: #a884e0;
    --c4-bg: #451f31; --c4-line: #e87aa5;
    --c5-bg: #10353a; --c5-line: #43b8c4;
    --c6-bg: #2a303c; --c6-line: #94a1b5;
    --c7-bg: #3b2d1e; --c7-line: #c4915a;

    --err: #ff8098;
    --err-bg: #3a1b23;
    --err-line: #7a3548;
    --warn: #f0b95c;
    --warn-bg: #3a2c12;
    --warn-line: #7a5c22;
    --info: #86c4e0;
    --info-bg: #17303c;
    --info-line: #2f5a70;
    --ok: #6fd3a0;
    --ok-bg: #16352a;
    --ok-line: #2d6a4c;
    --badge-warn: #b57a12;
    --off-day: #5b6880;

    --header-from: #18213a;
    --header-to: #27406f;
    --header-ink: #eaf0fb;
    --toast-bg: #e6eaf2;
    --toast-ink: #131722;
    --shadow: 0 2px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 6px 22px rgba(0, 0, 0, .6);
  }
}

/* ===== ערכה כהה – לפי בחירה מפורשת ===== */
:root[data-theme="dark"] {
  --bg: #131722;
  --surface: #1b2130;
  --surface-head: #232b3d;
  --surface-row: #202736;
  --surface-sunken: #1f2635;
  --input-bg: rgba(255, 255, 255, .06);
  --ink: #e6eaf2;
  --muted: #97a3b8;
  --line: #313a4e;
  --brand: #6d91f0;
  --brand-dark: #4d72d8;
  --brand-ink: #10141d;
  --closed-a: #1a202d;
  --closed-b: #222a3a;

  --morning: #4a3a14;
  --morning-line: #d99f22;
  --middle: #123a2c;
  --middle-line: #35b184;
  --evening: #1f2b50;
  --evening-line: #7590e8;

  --c0-bg: #4a3a14; --c0-line: #d99f22;
  --c1-bg: #123a2c; --c1-line: #35b184;
  --c2-bg: #1f2b50; --c2-line: #7590e8;
  --c3-bg: #33224d; --c3-line: #a884e0;
  --c4-bg: #451f31; --c4-line: #e87aa5;
  --c5-bg: #10353a; --c5-line: #43b8c4;
  --c6-bg: #2a303c; --c6-line: #94a1b5;
  --c7-bg: #3b2d1e; --c7-line: #c4915a;

  --err: #ff8098;
  --err-bg: #3a1b23;
  --err-line: #7a3548;
  --warn: #f0b95c;
  --warn-bg: #3a2c12;
  --warn-line: #7a5c22;
  --info: #86c4e0;
  --info-bg: #17303c;
  --info-line: #2f5a70;
  --ok: #6fd3a0;
  --ok-bg: #16352a;
  --ok-line: #2d6a4c;
  --badge-warn: #b57a12;
  --off-day: #5b6880;

  --header-from: #18213a;
  --header-to: #27406f;
  --header-ink: #eaf0fb;
  --toast-bg: #e6eaf2;
  --toast-ink: #131722;
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 6px 22px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* כיוון הכתיבה מגיע מתכונת dir של המסמך, שנקבעת לפי השפה הפעילה.
   אסור לקבע אותו כאן – אחרת אנגלית וספרדית ייראו מימין לשמאל. */
body {
  margin: 0;
  font-family: "Segoe UI", "Rubik", "Arial Hebrew", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

/* ===== כותרת ולשוניות ===== */
.app-header {
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  color: var(--header-ink);
  padding: 14px 16px 0;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.app-header h1 { margin: 0; font-size: 20px; }
.sub { margin: 2px 0 10px; font-size: 13px; opacity: .88; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: rgba(255, 255, 255, .14);
  border: 0; color: var(--header-ink); cursor: pointer;
  padding: 9px 16px; font-size: 14px; font-family: inherit;
  border-radius: 10px 10px 0 0;
}
.tab:hover { background: rgba(255, 255, 255, .26); }
.tab.active { background: var(--bg); color: var(--ink); font-weight: 700; }
.tab:focus-visible, .btn:focus-visible, .chip:focus-visible,
.pill:focus-visible, .cstate:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

h2 { font-size: 17px; margin: 18px 0 10px; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  font-family: inherit; font-size: 14px; cursor: pointer;
  border-radius: 9px; padding: 9px 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); color: var(--brand-ink); }
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: var(--err); color: var(--surface); }
.btn.ghost.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 4px 9px; line-height: 1.2; }
.file-btn { display: inline-flex; align-items: center; }

.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { display: flex; flex-direction: column; min-width: 180px; text-align: center; }
.week-label span { font-size: 12px; color: var(--muted); }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

.sync-state { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.sync-state::before { content: "●"; color: var(--muted); font-size: 10px; }
.sync-state.live::before { color: var(--ok); }
.sync-state.local::before { color: var(--badge-warn); }

.view-switch { display: flex; gap: 6px; margin: 10px 0; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ===== טבלאות ===== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; vertical-align: top; font-size: 13px; }
thead th { background: var(--surface-head); position: sticky; top: 0; z-index: 2; font-size: 13px; }
th.day-head small { display: block; font-weight: 400; color: var(--muted); }
td.row-head, th.row-head { background: var(--surface-row); text-align: start; font-weight: 600; white-space: nowrap; }
tr.branch-start td, tr.branch-start th { border-top: 2px solid var(--brand); }
td.closed {
  background: repeating-linear-gradient(45deg, var(--closed-a), var(--closed-a) 6px, var(--closed-b) 6px, var(--closed-b) 12px);
  color: var(--muted);
}

/* צבעי המשמרות: לוח קבוע שכל עסק בוחר ממנו לכל משמרת שהגדיר */
.sh { background: var(--sh-bg); border-inline-start: 4px solid var(--sh-line); }
.sh-0 { --sh-bg: var(--c0-bg); --sh-line: var(--c0-line); }
.sh-1 { --sh-bg: var(--c1-bg); --sh-line: var(--c1-line); }
.sh-2 { --sh-bg: var(--c2-bg); --sh-line: var(--c2-line); }
.sh-3 { --sh-bg: var(--c3-bg); --sh-line: var(--c3-line); }
.sh-4 { --sh-bg: var(--c4-bg); --sh-line: var(--c4-line); }
.sh-5 { --sh-bg: var(--c5-bg); --sh-line: var(--c5-line); }
.sh-6 { --sh-bg: var(--c6-bg); --sh-line: var(--c6-line); }
.sh-7 { --sh-bg: var(--c7-bg); --sh-line: var(--c7-line); }

/* תאימות לאחור לסגנונות שעדיין מזכירים את שלוש המשמרות המקוריות */
.shift-morning { background: var(--c0-bg); border-inline-start: 4px solid var(--c0-line); }
.shift-middle  { background: var(--c1-bg); border-inline-start: 4px solid var(--c1-line); }
.shift-evening { background: var(--c2-bg); border-inline-start: 4px solid var(--c2-line); }

td.cell { min-width: 130px; }
td.cell.has-error { outline: 2px solid var(--err); outline-offset: -2px; }
td.cell.has-warning { outline: 2px dashed var(--badge-warn); outline-offset: -2px; }

select.emp-select {
  width: 100%; font-family: inherit; font-size: 13px; padding: 4px 6px; margin-bottom: 3px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--input-bg); color: var(--ink);
}
select.emp-select.extra { border-style: dashed; color: var(--muted); }

/* ===== פאנל התראות ===== */
.issues { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.issue { padding: 8px 12px; border-radius: 9px; font-size: 13.5px; border: 1px solid transparent; }
.issue.error { background: var(--err-bg); color: var(--err); border-color: var(--err-line); font-weight: 600; }
.issue.warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.issue.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.issues-summary { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 2px; }
.badge { border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 700; color: #fff; }
.badge.error { background: var(--err); color: var(--surface); }
.badge.warning { background: var(--badge-warn); color: #fff; }
.badge.info { background: var(--info); color: var(--surface); }
.badge.ok { background: var(--ok); color: var(--surface); }
.issues-toggle { background: none; border: 0; color: var(--brand); cursor: pointer; font-family: inherit; font-size: 13px; text-decoration: underline; }

.workload { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.load-pill {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.load-pill b { color: var(--brand); }
.load-pill.over { border-color: var(--err); color: var(--err); }
.load-pill.over b { color: var(--err); }
.load-pill.zero { color: var(--muted); }

/* ===== כרטיסים ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card.inactive { opacity: .6; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head input.name {
  font-size: 15px; font-weight: 700; border: 1px solid transparent; background: transparent;
  border-radius: 7px; padding: 4px 6px; width: 100%; font-family: inherit; color: var(--ink);
}
.card-head input.name:hover, .card-head input.name:focus { border-color: var(--line); background: var(--surface-sunken); outline: none; }
.field { margin-bottom: 9px; }
.field > label.title { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: var(--surface-sunken); border-radius: 999px;
  padding: 4px 11px; font-size: 12.5px; cursor: pointer; user-select: none; font-family: inherit; color: var(--muted);
}
.pill.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.num-input, .text-input {
  font-family: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 7px; width: 100%; background: var(--input-bg); color: var(--ink);
}
.num-input { width: 74px; }
.need-row { display: flex; gap: 10px; flex-wrap: wrap; }
.need-row label { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }

/* ===== אילוצים ===== */
.cstate {
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px; font-size: 12px;
  cursor: pointer; font-family: inherit; margin: 1px; min-width: 42px;
  background: var(--surface); color: var(--muted);
}
.cstate.pref { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); font-weight: 700; }
.cstate.block { background: var(--err-bg); border-color: var(--err-line); color: var(--err); font-weight: 700; text-decoration: line-through; }
.cstate.off-day { background: var(--off-day); border-color: var(--off-day); color: #fff; font-weight: 700; }
.day-off-btn { display: block; width: 100%; margin-top: 3px; }
.legend { border-radius: 6px; padding: 1px 8px; font-size: 12px; margin: 0 2px; }
.legend.free { background: var(--surface); border: 1px solid var(--line); }
.legend.pref { background: var(--ok-bg); color: var(--ok); }
.legend.block { background: var(--err-bg); color: var(--err); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 12px; }

.settings-block { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.settings-block.row { flex-direction: row; flex-wrap: wrap; align-items: center; }

.emp-chip { display: block; border-radius: 6px; padding: 2px 6px; margin: 2px 0; font-size: 12.5px; }
.emp-chip.dup { outline: 2px solid var(--err); font-weight: 700; }
.empty-cell { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--toast-bg); color: var(--toast-ink); padding: 11px 20px; border-radius: 10px;
  font-size: 14px; transition: transform .25s; z-index: 50; box-shadow: var(--shadow-lg);
  max-width: min(92vw, 420px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 640px) {
  .app-header h1 { font-size: 17px; }
  .sub { font-size: 12px; }
  main { padding: 12px 16px; }
  .cards { grid-template-columns: 1fr; }
  .week-label { min-width: 140px; }
}

@media print {
  .no-print, .app-header, .view-switch, .workload { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  main { padding: 0; max-width: none; }
  .panel { display: none !important; }
  .panel.active { display: block !important; }
  .table-wrap { border: 0; overflow: visible; }
  table { min-width: 0; }
  select.emp-select { border: 0; background: transparent; appearance: none; -webkit-appearance: none; padding: 1px; color: #000; }
  select.emp-select.extra { display: none; }
  .issue.info { display: none; }
  @page { size: landscape; margin: 10mm; }
}

/* ===== שעות בתאי הסידור ===== */
.cell-hours {
  font-size: 11px; color: var(--muted); margin-bottom: 3px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.cell-hours .missing { color: var(--err); font-weight: 600; }

.shabbat-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.time-input {
  font-family: inherit; font-size: 13px; padding: 4px 7px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--input-bg); color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ===== עורך הימים והשעות של הסניף ===== */
.card.wide { grid-column: 1 / -1; }
.sched-wrap { margin-top: 4px; }
.sched-table { min-width: 620px; }
.sched-table th { font-size: 13px; }
td.sched-cell { min-width: 150px; vertical-align: middle; }
td.sched-cell.closed { background: none; }
.sched-need { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.sched-need .num-input { width: 58px; }
.sched-times { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 5px; }
.sched-times .time-input { width: 88px; padding: 3px 5px; }
.sched-times .dash { color: var(--muted); }
.sched-times .auto-time {
  font-size: 11.5px; color: var(--ink); background: var(--surface-sunken);
  border: 1px dashed var(--line); border-radius: 6px; padding: 3px 7px; white-space: nowrap;
}
.sched-closed { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.check.tiny { font-size: 11.5px; color: var(--muted); justify-content: center; margin-top: 4px; }
.copy-row { margin-top: 10px; max-width: 320px; }

/* ===== ימי חג ===== */
.holiday-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.holiday-label { font-size: 13px; color: var(--muted); }
.holiday-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.holiday-chip { padding: 4px 12px; font-size: 12.5px; }
.holiday-chip.active {
  background: var(--err-bg); border-color: var(--err-line); color: var(--err); font-weight: 700;
}
td.holiday-cell {
  background: var(--err-bg); color: var(--err); font-weight: 600; vertical-align: middle;
}
td.holiday-cell small { display: block; font-weight: 400; opacity: .8; }
.holiday-text { color: var(--err); font-weight: 600; }

/* ===== סיכום יתרת הזמינות ===== */
.availability {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
}
.summary-title { margin: 0 0 8px; font-size: 15px; }
.summary-line { margin: 0 0 10px; font-size: 14px; }
.summary-line.total b { color: var(--brand); }
.summary-line.none { color: var(--muted); }
.summary-empty { color: var(--muted); font-size: 14px; margin: 0; }
.summary-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.summary-list li {
  font-size: 13.5px; padding: 6px 11px; border-radius: 8px;
  border-inline-start: 3px solid var(--line); background: var(--surface-sunken);
}
.summary-list li.has-spare { border-inline-start-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.summary-list li.has-spare b { color: inherit; }
.summary-list li.no-days { border-inline-start-color: var(--badge-warn); background: var(--warn-bg); color: var(--warn); }
.summary-list li.full { color: var(--muted); }

/* ===== ייצוא אישי לעובד ===== */
.personal-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.personal-label { font-size: 13px; color: var(--muted); }
.personal-select { width: auto; min-width: 170px; }

/* ===== צ'אט שאלות על הסידור ===== */
.chat {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
}
.chat-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chat-messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chat-messages:empty { display: none; }
.chat-msg {
  padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.55;
  max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-msg.user { align-self: flex-start; background: var(--brand); color: var(--brand-ink); }
.chat-msg.bot { align-self: flex-end; background: var(--surface-sunken); border: 1px solid var(--line); }
.chat-msg.error { align-self: flex-end; background: var(--err-bg); color: var(--err); border: 1px solid var(--err-line); }
.chat-msg.pending { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 8px; }
.chat-form .text-input { flex: 1; }
.chat-form .btn { white-space: nowrap; }

/* ===================== אייפון / נייד ===================== */
.mobile-only { display: none; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { -webkit-tap-highlight-color: transparent; }

/* גלילה חלקה בטבלאות רחבות */
.table-wrap { -webkit-overflow-scrolling: touch; }

/* בורר היום – הרצועה העליונה בנייד */
.day-nav {
  gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px; scrollbar-width: none;
}
.day-nav::-webkit-scrollbar { display: none; }
.day-tab {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 52px; padding: 7px 4px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-family: inherit; line-height: 1.2;
}
.day-tab-name { font-size: 14px; font-weight: 700; }
.day-tab-date { font-size: 10.5px; opacity: .85; font-variant-numeric: tabular-nums; }
.day-tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.day-tab.holiday { border-color: var(--err-line); color: var(--err); background: var(--err-bg); }
.day-tab.holiday.active { background: var(--err); color: #fff; border-color: var(--err); }

/* כרטיסי היום */
.m-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 10px; overflow: hidden;
}
.m-card-head {
  padding: 10px 14px; font-weight: 700; font-size: 15px;
  background: var(--surface-head); border-bottom: 1px solid var(--line);
}
.m-shift { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.m-shift:last-child { border-bottom: 0; }
.m-shift-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 7px;
}
.m-shift-head b { font-size: 14.5px; }
.m-shift-head span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.m-shift.flag-error { box-shadow: inset 3px 0 0 var(--err); }
.m-shift.flag-warning { box-shadow: inset 3px 0 0 var(--badge-warn); }
.m-shift .emp-select { margin-bottom: 6px; }
.m-shift .emp-select:last-child { margin-bottom: 0; }
.m-closed { padding: 14px; color: var(--muted); font-size: 13.5px; text-align: center; }
.m-holiday {
  padding: 18px 14px; text-align: center; font-size: 16px; font-weight: 700; color: var(--err);
}
.m-holiday small { display: block; margin-top: 4px; font-weight: 400; font-size: 13px; color: var(--muted); }
.m-card.holiday { border-color: var(--err-line); }
.m-constraint .m-card-head { font-size: 14px; padding: 8px 12px; }
.m-cstates { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.m-cstates .cstate { flex: 1 1 auto; min-width: 70px; min-height: 40px; font-size: 13.5px; }

@media (max-width: 820px) {
  .mobile-only { display: block; }
  .day-nav.mobile-only { display: flex; }
  .desktop-only { display: none !important; }
  .view-switch { display: none; }

  /* אזורים בטוחים של האייפון: מגן המסך למעלה ופס הבית למטה */
  .app-header {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 0;
    position: sticky; top: 0; z-index: 20;
  }
  main {
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .app-header h1 { font-size: 16px; }
  .sub { display: none; }
  .logo { font-size: 24px; }

  /* לשוניות ניתנות לגלילה במקום לרדת שורה */
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin: 0 -14px; padding: 0 14px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 9px 13px; font-size: 13.5px; }

  /* יעדי מגע נוחים, וללא זום אוטומטי בהתמקדות על שדה */
  .btn { min-height: 42px; padding: 10px 14px; }
  .btn.ghost.small { min-height: 38px; }
  select.emp-select, .text-input, .num-input, .time-input {
    font-size: 16px; min-height: 42px; padding: 9px 11px;
  }
  .num-input { width: 82px; }
  .cstate { min-height: 38px; padding: 6px 10px; font-size: 13px; }
  .chip, .holiday-chip { min-height: 36px; }
  .check { min-height: 34px; }
  input[type="checkbox"] { width: 20px; height: 20px; }

  .toolbar { gap: 8px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  #generate { flex-basis: 100%; }
  .week-nav { width: 100%; justify-content: space-between; }
  .week-label { min-width: auto; flex: 1; }

  .personal-bar, .holiday-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .personal-select { width: 100%; min-width: 0; }
  .personal-bar .btn { width: 100%; }

  .issue { font-size: 13px; padding: 9px 11px; }
  .workload { gap: 6px; }
  .load-pill { font-size: 12.5px; padding: 5px 10px; }
  .summary-list li { font-size: 13px; }
  .chat-msg { max-width: 92%; }
  .chat-form { flex-direction: column; }
  .chat-form .btn { width: 100%; }

  .sched-table { min-width: 560px; }
  .sched-times .time-input { width: 96px; }
}

/* מסכים צרים במיוחד */
@media (max-width: 380px) {
  main { padding-inline: 12px; }
  .day-tab { min-width: 46px; padding: 6px 2px; }
  .m-card-head { font-size: 14px; }
}

/* במצב אפליקציה (הוסף למסך הבית) אין סרגל דפדפן */
@media (display-mode: standalone) {
  .app-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
}

/* ===== כלים נוספים (מקופלים בנייד) ===== */
.more-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.tools-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 820px) {
  .more-tools {
    display: none;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 12px;
  }
  .more-tools.open { display: flex; }
  .more-tools .personal-bar,
  .more-tools .holiday-bar { border: 0; padding: 0; background: none; }
  .more-tools .tools-row .btn { flex: 1 1 45%; }
  .week-label strong { font-size: 14px; white-space: nowrap; }
  .week-label span { font-size: 11px; }
  .week-nav .btn { padding: 8px 12px; }
  #this-week { order: 3; }
  .sync-state { order: 4; width: 100%; justify-content: center; }
  #tools-toggle { flex: 1 1 100%; }
}

/* הודעה בעותק מקומי של הקובץ */
.local-notice {
  margin: 0 0 12px; padding: 9px 13px; border-radius: 9px; font-size: 13px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line);
}

/* ===== מצב צפייה ===== */
.view-only-banner {
  margin: 0 0 12px; padding: 9px 13px; border-radius: 9px; font-size: 13.5px;
  background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line);
}
body.view-only select.emp-select,
body.view-only .cstate,
body.view-only .pill,
body.view-only .holiday-chip,
body.view-only .card input,
body.view-only .card select { opacity: .75; cursor: not-allowed; }
body.view-only #view-only-toggle { border-color: var(--info); color: var(--info); font-weight: 600; }
body.view-only .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== שעות ברירת מחדל ===== */
.hours-grid { display: flex; flex-direction: column; gap: 8px; }
.hours-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hours-name {
  min-width: 78px; padding: 5px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; text-align: center;
}
.hours-row .time-input { width: 104px; }
.hours-row .dash { color: var(--muted); }

/* ===================== שער התחברות ושורת משתמש ===================== */
.auth-gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: var(--bg);
}
.auth-gate.hidden { display: none; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-title { margin: 0; font-size: 20px; }
.auth-sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-sunken);
  color: var(--muted); font-family: inherit; font-size: 13.5px;
}
.auth-tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }
.auth-form .text-input { font-size: 16px; padding: 10px 12px; }
.auth-form small { font-size: 12px; color: var(--muted); }
.auth-form .btn { margin-top: 4px; padding: 11px; font-size: 15px; }
.auth-error {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
  background: var(--err-bg); color: var(--err); border: 1px solid var(--err-line);
}
/* הודעה חיובית במסך הכניסה – "נשלח מייל אישור" אינו כישלון */
.auth-notice {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line);
}
.auth-hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; text-align: center; }
.auth-blocked { text-align: center; padding: 8px 0 18px; }
.auth-blocked h2 { font-size: 17px; margin: 0 0 8px; color: var(--err); }
.auth-blocked p { font-size: 14px; color: var(--ink); margin: 0 0 6px; }

.user-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.user-bar.hidden { display: none; }
.user-company { font-weight: 700; }
.user-name { color: var(--muted); }
.user-notice {
  margin-inline-start: auto; padding: 3px 10px; border-radius: 999px;
  background: var(--info-bg); color: var(--info); font-size: 12.5px;
}
.user-notice.warn { background: var(--warn-bg); color: var(--warn); }
.user-bar .btn { margin-inline-start: auto; }
.user-notice ~ .btn { margin-inline-start: 0; }

/* ===================== מסך העובד וניהול משתמשים ===================== */
.employee-root { padding: 16px; max-width: 760px; margin: 0 auto; }
.employee-root.hidden { display: none; }
.employee-weeknav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; font-size: 15px;
}
.employee-title { font-size: 16px; margin: 20px 0 10px; }
.employee-note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.employee-flash {
  margin: 0 0 12px; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line);
}
.employee-shifts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.employee-shift {
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  border-inline-start-width: 4px; border-inline-start-style: solid;
}
.employee-shift b { font-size: 15px; }
.employee-shift span { font-size: 12.5px; color: var(--muted); margin-inline-start: 6px; }
.employee-shift div { font-size: 13.5px; margin-top: 4px; }
.employee-shift small { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.employee-days { display: flex; flex-direction: column; gap: 10px; }

.invite-form h3 { margin: 0 0 4px; font-size: 15px; }
.invite-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.invite-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); flex: 1 1 180px; }
.users-message {
  margin: 6px 0 0; font-size: 13px; padding: 7px 11px; border-radius: 8px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line);
}
.users-message.error { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.users-message.hidden { display: none; }
.tab.hidden { display: none; }

/* ===================== מנוי ותוכניות ===================== */
.billing-current { gap: 8px; }
.billing-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.billing-row span { color: var(--muted); }
.billing-row b.status-trial { color: var(--info); }
.billing-row b.status-active { color: var(--ok); }
.billing-row b.status-past_due { color: var(--warn); }
.billing-row b.status-canceled, .billing-row b.status-expired { color: var(--err); }
.billing-note {
  margin: 4px 0 0; font-size: 13px; padding: 8px 11px; border-radius: 8px;
  background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line);
}
.billing-note.error { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 16px; text-align: center; display: flex; flex-direction: column; gap: 8px;
}
.plan-card.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.plan-card.too-small { opacity: .6; }
.plan-name { font-size: 15px; font-weight: 700; }
.plan-price { font-size: 30px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.plan-price small { font-size: 13px; font-weight: 400; color: var(--muted); margin-inline-start: 3px; }
.plan-range { font-size: 13px; color: var(--muted); }
.plan-tag { font-size: 12.5px; color: var(--brand); font-weight: 600; padding: 6px 0; }
.plan-tag.warn { color: var(--warn); }
.plan-card .btn { margin-top: auto; }

/* ===================== בקשות אילוץ לאישור ===================== */
.pending-panel {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.pending-panel.hidden { display: none; }
.pending-title { margin: 0 0 4px; font-size: 15px; color: var(--warn); }
.pending-panel .hint { margin: 0 0 10px; }
.pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 13px; flex-wrap: wrap;
}
.pending-info { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.pending-info span { color: var(--muted); font-size: 12.5px; }
.pending-info em { font-style: normal; color: var(--ink); }
.pending-info small { color: var(--muted); font-size: 12.5px; }
.pending-actions { display: flex; gap: 6px; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.approve { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn.approve:hover { background: var(--ok); color: #fff; opacity: .9; }
.btn.reject:hover { border-color: var(--err); color: var(--err); }

.c-status { font-size: 11px; margin-top: 4px; padding: 2px 6px; border-radius: 6px; line-height: 1.35; }
.c-status.pending { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn-line); }
.c-status.rejected { background: var(--err-bg); color: var(--err); }

/* סטטוס בקשת אילוץ במסך העובד */
.req-badge {
  float: inline-end; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}
.req-badge.pending { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.req-badge.approved { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.req-badge.rejected { background: var(--err-bg); color: var(--err); border: 1px solid var(--err-line); }
.req-note { font-size: 12.5px; color: var(--muted); margin: 0; padding: 0 12px 10px; }

/* סיבה שהעובד מצרף לבקשה */
.req-reason { padding: 0 12px 10px; }
.req-reason label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.req-reason .text-input { font-size: 15px; }
.c-status.approved { background: var(--ok-bg); color: var(--ok); }

/* ===================== ניהול סוגי המשמרות ===================== */
.shift-grid { display: flex; flex-direction: column; gap: 10px; }
.shift-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); border-inline-start-width: 4px; border-inline-start-style: solid;
}
.shift-row .shift-name { flex: 1 1 150px; font-weight: 600; background: var(--surface); }
.shift-times { display: flex; align-items: center; gap: 6px; }
.shift-times .time-input { width: 96px; background: var(--surface); }
.shift-colors { display: flex; gap: 4px; }
.color-dot {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid transparent; background: var(--sh-bg);
  box-shadow: inset 0 0 0 2px var(--sh-line);
}
.color-dot.active { border-color: var(--ink); }
.shift-actions { display: flex; gap: 4px; margin-inline-start: auto; }
.shift-actions .btn { padding: 4px 9px; }

/* בורר השפה בשורת המשתמש ובמסך הכניסה */
.user-lang {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: inherit; font: inherit; font-size: 12.5px; padding: 3px 8px;
}
.auth-lang { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.auth-lang select { margin-inline-start: 6px; }

/* שורת אזהרה כשהמערכת רצה בלי שרת אמיתי */
.demo-banner {
  margin: 0; padding: 9px 16px; text-align: center; font-size: 13.5px;
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid var(--warn-line);
}
.demo-banner b { margin-inline-end: 6px; }

/* הודעת תקופת הניסיון בלשונית המנוי – הדבר הראשון שרואים שם */
.billing-trial {
  margin: 0 0 14px; padding: 12px 15px; border-radius: 11px; font-size: 14px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line);
}
.billing-trial.warn {
  background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line);
}
