/* ===== בסיס ===== */
:root {
  --font: "Assistant", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --surface-3: #e9e5dc;
  --line: #e2ddd3;
  --line-2: #cbc4b6;
  --ink: #2b2a26;
  --ink-2: #5d5a52;
  --ink-3: #8c887d;
  --accent: #2f6a5e;
  --accent-hover: #27584e;
  --accent-soft: #e2eeea;
  --accent-ink: #ffffff;
  --warn: #a8581c;
  --warn-soft: #fbeadb;
  --danger: #a33c3c;
  --danger-soft: #f8e4e4;
  --r: 6px;
  --r-lg: 10px;
  --shadow: 0 1px 2px rgba(40, 35, 20, .06);
  --shadow-lg: 0 12px 40px rgba(40, 35, 20, .16);
}
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

/* ===== סרגל עליון ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 58px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 38px; width: auto; max-width: 120px; object-fit: contain; }
.brand-title { font-weight: 700; font-size: 17px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--ink-3); line-height: 1.2; }
.tabs { display: flex; gap: 2px; }
.tabs a {
  padding: 7px 12px; border-radius: var(--r); color: var(--ink-2);
  text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a.active { color: var(--accent); background: var(--accent-soft); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }

.sync {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-2);
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
  white-space: nowrap; cursor: default;
}
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.sync.cloud .dot { background: var(--accent); }
.sync.saving .dot { animation: pulse 1s infinite; }
.sync.error { background: var(--danger-soft); color: var(--danger); }
.sync.error .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .25; } }
ol.steps { margin: 8px 0; padding-inline-start: 22px; line-height: 1.6; }
ol.steps li { margin: 4px 0; }

/* ===== כפתורים ===== */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 14px; line-height: 1.2;
  padding: 7px 14px; border-radius: var(--r); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { border-color: #e2c3c3; }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 30px; height: 30px; justify-content: center; font-size: 18px; }
.btn.icon.sm { width: 26px; height: 26px; font-size: 14px; }
.btn.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.btn.warn:hover { background: #f6dcc4; }

/* ===== פקדים ===== */
.ctl, .field input, .field select {
  font-size: 14px; padding: 6px 10px; min-height: 34px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
}
.ctl:focus, .field input:focus, .field select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="time"], input[type="number"] { direction: ltr; text-align: right; }
input[type="search"] { min-width: 200px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; }
.seg button {
  border: 0; background: transparent; font-weight: 600; font-size: 14px;
  padding: 5px 14px; border-radius: 6px; color: var(--ink-2); cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400 !important; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.chk-row { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* ===== תצוגה ===== */
main { padding: 16px 20px 60px; }
.view-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.view-head h1 { font-size: 20px; margin: 0; font-weight: 700; }
.view-head .sub { font-size: 13px; color: var(--ink-3); }

/* ===== לוח השיבוץ ===== */
.board-wrap {
  overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  max-height: calc(100vh - 150px);
}
table.board { border-collapse: separate; border-spacing: 0; min-width: 100%; table-layout: fixed; }
.board th, .board td {
  border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line);
  vertical-align: top; padding: 6px;
}
.board th:first-child, .board td:first-child { border-inline-start: 0; }
.board th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2); font-weight: 700; font-size: 13.5px; color: var(--ink-2);
  text-align: center; padding: 10px 6px; white-space: nowrap;
}
.board th.c-seats { inset-inline-start: 0; z-index: 4; }
.board th.c-room { inset-inline-start: 72px; z-index: 4; }
.board col.c-seats { width: 72px; }
.board col.c-room { width: 150px; }
.board col.c-day { min-width: 150px; }
.board td.seats {
  position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface);
  text-align: center; font-size: 12.5px; color: var(--ink-2); direction: ltr; font-variant-numeric: tabular-nums;
  padding-top: 9px;
}
.board td.room {
  position: sticky; inset-inline-start: 72px; z-index: 2; background: var(--surface);
  font-weight: 700; font-size: 14px; padding-top: 8px;
}
.board td.room .room-sub { font-weight: 400; font-size: 11.5px; color: var(--ink-3); }
.board tr.lab td.seats, .board tr.lab td.room { background: var(--surface-3); }
.board tr.grp td { background: var(--surface-2); padding: 4px 10px; font-weight: 700; font-size: 12.5px; color: var(--ink-2); }
.board tr.grp td.grp-name { position: sticky; inset-inline-start: 0; z-index: 2; }
.board td.cell { position: relative; height: 50px; }
.board td.cell.over { background: var(--accent-soft); }
.cell-add {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 20px; line-height: 1; opacity: 0; transition: opacity .12s; padding: 0;
}
.cell-add.full { position: absolute; inset: 0; width: 100%; }
.cell-add.small {
  position: absolute; bottom: 2px; inset-inline-start: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--surface-2); font-size: 15px;
}
.board td.cell:hover .cell-add { opacity: .6; }
.cell-add:hover { opacity: 1 !important; color: var(--accent); }
.entries { display: flex; flex-direction: column; gap: 5px; }
.entry {
  --t-bar: #9a978f; --t-bg: #e6e5e1; --t-fg: #3d3c38;
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-inline-start: 3px solid var(--t-bar);
  border-radius: 5px; padding: 5px 8px 5px 7px; font-size: 12.5px; line-height: 1.3; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.entry:hover { border-color: var(--t-bar); background: color-mix(in srgb, var(--t-bg) 35%, var(--surface)); }
.entry.dim { opacity: .28; }
.entry.dragging { opacity: .4; }
.entry .l1 { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.entry .chip {
  display: inline-block; font-size: 10.5px; font-weight: 700; line-height: 1.5;
  padding: 0 7px; border-radius: 999px; background: var(--t-bg); color: var(--t-fg); white-space: nowrap;
}
.entry .cls { font-weight: 700; }
.entry .course { margin-top: 1px; }
.entry .l3 { display: flex; flex-wrap: wrap; gap: 2px 8px; color: var(--ink-2); font-size: 12px; margin-top: 1px; }
.entry .hrs { color: var(--ink-3); direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.entry .note { color: var(--warn); font-size: 11.5px; margin-top: 1px; }
.entry .warn { display: inline-flex; width: 14px; height: 14px; color: var(--warn); margin-inline-start: auto; }
.entry .warn svg { display: block; width: 14px; height: 14px; }

/* ===== טבלאות רשימה ===== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card p { margin: 6px 0; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; font-size: 14px; vertical-align: middle; }
.list th { background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tr.grp td { background: var(--surface-2); font-weight: 700; padding: 6px 10px; }
.list tr.inactive td { color: var(--ink-3); }
.list td.actions { white-space: nowrap; text-align: end; }
.list td.actions .btn { margin-inline-start: 2px; }
.list .seats-lbl { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.grp-actions { display: inline-flex; gap: 2px; margin-inline-start: 10px; vertical-align: middle; }

/* ===== לוח אישי (מרצה / כיתת לימוד) ===== */
table.week { width: 100%; border-collapse: collapse; table-layout: fixed; }
.week th, .week td { border: 1px solid var(--line); padding: 6px; vertical-align: top; font-size: 13px; }
.week th { background: var(--surface-2); font-size: 13px; color: var(--ink-2); text-align: center; }
.week td.shift { background: var(--surface-2); font-weight: 700; width: 60px; text-align: center; vertical-align: middle; }
.week .wi { padding: 4px 6px; margin-bottom: 4px; border-radius: 4px; background: var(--surface-2); border-inline-start: 3px solid var(--t-bar, var(--line-2)); cursor: pointer; }
.week .wi:hover { background: var(--accent-soft); }
.week .wi b { display: block; }
.week .wi .hrs { color: var(--ink-3); direction: ltr; unicode-bidi: isolate; font-size: 12px; }

/* ===== הגדרות ===== */
.settings { max-width: 880px; }
.settings .grid2 { max-width: 620px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
.swatches { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--ink); }
.logo-preview { height: 56px; width: auto; max-width: 200px; object-fit: contain; background: var(--surface-2); border-radius: var(--r); padding: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.list.compact td, .list.compact th { padding: 5px 10px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--ink-2); }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; direction: ltr; unicode-bidi: isolate; }

/* ===== דיאלוגים ===== */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0;
  box-shadow: var(--shadow-lg); width: min(580px, calc(100vw - 32px));
  color: var(--ink); background: var(--surface); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(40, 35, 25, .38); }
.dlg-head { padding: 16px 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 14px 20px 4px; overflow: auto; max-height: calc(100vh - 170px); }
.dlg-foot { padding: 12px 20px 16px; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field.full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--ink-3); }
.form-error { margin-top: 10px; padding: 8px 12px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.issues { margin: 0; padding: 0 18px 0 0; }
.issues li { margin: 4px 0; font-size: 14px; }
.issues li::marker { color: var(--warn); }
p.hint { line-height: 1.5; }

/* ===== התנגשויות ===== */
.conflicts { margin-top: 12px; padding: 10px 12px; border-radius: var(--r); border: 1px solid; font-size: 13.5px; }
.conflicts.err { background: var(--danger-soft); border-color: #e4bcbc; color: #6b2424; }
.conflicts.warn { background: var(--warn-soft); border-color: #ecd0b6; color: #6b3a10; }
.conflicts-title { font-weight: 700; margin-bottom: 4px; }
.conflicts ul { margin: 0 0 8px; padding-inline-start: 18px; }
.conflicts li { margin: 2px 0; }
.conflicts .chk { font-weight: 700 !important; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: currentColor; font-size: 11.5px; line-height: 18px; text-align: center; }
.badge { color: #fff; background: var(--ink-2); }
.btn.warn .badge { background: var(--warn); }
.btn.danger-soft { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn.danger-soft:hover { background: #f1d4d4; }
.btn.danger-soft .badge { background: var(--danger); }
.btn .badge { margin-inline-start: 2px; }
.ctl.sem { font-weight: 700; min-width: 150px; }
.entry.err { border-color: #d9a0a0; }
.entry .warn.err { color: var(--danger); }
option.busy { color: var(--danger); }
.sev-err { color: var(--danger); font-size: 15px; margin: 6px 0 4px; }
.sev-warn { color: var(--warn); font-size: 15px; margin: 10px 0 4px; }
.issues.err li::marker { color: var(--danger); }
.ok-msg { color: var(--accent); font-weight: 600; margin: 4px 0 8px; }
.list tr.current td { background: #f6faf8; }
.sub-h { font-size: 14.5px; margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--line); }
a.btn { text-decoration: none; }

/* ===== הודעות ===== */
#toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--r); font-size: 14px;
  display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out;
  max-width: min(460px, calc(100vw - 36px));
}
.toast button { background: transparent; border: 0; color: #9fd6c4; font-weight: 700; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ===== ריק ===== */
.empty { padding: 40px; text-align: center; color: var(--ink-3); }

/* ===== מסכים קטנים ===== */
@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px 14px; }
  .topbar-actions { margin-inline-start: 0; width: 100%; justify-content: flex-start; }
  .tabs { order: 3; width: 100%; overflow: auto; }
  main { padding: 12px; }
  .board-wrap { max-height: none; }
  .board col.c-room { width: 120px; }
  .board th.c-room, .board td.room { inset-inline-start: 60px; }
  .board col.c-seats { width: 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}

/* ===== פריסת הדפסה / PDF (משותפת להדפסה ולייצוא PDF) ===== */
#print-root { display: none; }
#pdf-stage { position: fixed; top: 0; left: 0; z-index: -1; background: #fff; pointer-events: none; }
#app { position: relative; z-index: 0; background: var(--bg); min-height: 100vh; }
.print-page { color: #000; background: #fff; font-family: var(--font); font-size: 10px; direction: rtl; line-height: 1.3; }
.print-page.size-a3 { font-size: 13.5px; }
.print-page .print-head { display: flex; align-items: center; gap: 1.4em; margin-bottom: .7em; padding-bottom: .5em; border-bottom: 2px solid #222; }
.print-page .print-head img { height: 4.8em; width: auto; max-width: 16em; object-fit: contain; }
.print-page .print-head h1 { font-size: 2.1em; margin: 0; line-height: 1.1; }
.print-page .print-head h1 .cont { font-size: .55em; font-weight: 400; color: #555; }
.print-page .print-head .sub { font-size: 1.25em; color: #222; margin-top: .25em; }
.print-page .print-head .meta { margin-inline-start: auto; font-size: 1em; color: #444; text-align: end; line-height: 1.45; white-space: nowrap; }
.print-page table.pt { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .95em; }
.print-page .pt th, .print-page .pt td { border: 1px solid #333; padding: .3em .45em; vertical-align: top; }
.print-page .pt th { background: #e8e8e8; font-size: 1.1em; }
.print-page .pt col.c-seats { width: 5.2em; } .print-page .pt col.c-room { width: 9.5em; }
.print-page .pt td.seats { text-align: center; direction: ltr; font-size: .9em; }
.print-page .pt td.room { font-weight: 700; font-size: 1.1em; }
.print-page .pt tr.lab td.seats, .print-page .pt tr.lab td.room { background: #d9d9d9; }
.print-page .pt tr.grp td { background: #efefef; font-weight: 700; font-size: 1em; padding: .2em .6em; }
.print-page .pt tr.room-row td.cell { height: 2.6em; }
.print-page .pe { margin-bottom: .35em; line-height: 1.3; }
.print-page .pe b { font-weight: 700; }
.print-page .pe .hrs { direction: ltr; unicode-bidi: isolate; color: #222; white-space: nowrap; }
.print-page .pe .nt { color: #7a3b00; }
.print-page table.pw { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 1.05em; }
.print-page .pw th, .print-page .pw td { border: 1px solid #333; padding: .4em .5em; vertical-align: top; }
.print-page .pw th { background: #e8e8e8; }
.print-page .pw td.shift { font-weight: 700; background: #efefef; text-align: center; vertical-align: middle; width: 5em; }
.print-page .pw .wi { margin-bottom: .4em; } .print-page .pw .wi b { display: block; }
.print-page .pw .hrs { direction: ltr; unicode-bidi: isolate; }

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html, body { background: #fff; }
  #app, #toasts, dialog, #pdf-stage { display: none !important; }
  #print-root { display: block; }
  .print-page .pt tr, .print-page .pe { break-inside: avoid; }
  .print-page thead { display: table-header-group; }
}
