:root {
  --bg: #f4f9fd;
  --card: #ffffff;
  --border: #dfe6ee;
  --text: #101828;
  --muted: #5f6b7a;
  --pill-bg: #c9f2f6;
  --pill-text: #0d3a45;
  --primary: #237b93;
  --primary-hover: #1b6479;
  --primary-soft: #e3f3f7;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #05603a;
  --ok-soft: #e6f6ee;
  --warn: #b35c00;
  --warn-soft: #fef1e0;
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Heebo", "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid #0f6b85; outline-offset: 2px; }

.page { max-width: 780px; margin: 0 auto; padding: 28px 20px 64px; }
.page.wide { max-width: 1040px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.back {
  background: none; border: 0; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted);
  padding: 8px 10px; border-radius: 12px;
}
.back:hover { background: #e8f0f7; color: var(--text); }
.header { text-align: center; margin: 4px 0 30px; }
.pill {
  display: inline-block; background: var(--pill-bg); color: var(--pill-text);
  font-weight: 600; font-size: 15px; padding: 8px 22px; border-radius: 999px; margin-bottom: 18px;
}
.title { font-size: clamp(32px, 6vw, 48px); font-weight: 800; line-height: 1.15; margin: 0 0 14px; }
.subtitle { color: var(--muted); font-size: 19px; margin: 0 auto; max-width: 60ch; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.card-title { font-size: 22px; font-weight: 700; margin: 0 0 18px; }

.row { display: flex; gap: 14px; align-items: stretch; }
.row.wrap { flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 15px; margin-top: 4px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #f7fafc; border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 18px;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #7a8594; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; }
.checkline { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }

.btn {
  font: inherit; font-weight: 700; color: #fff; background: var(--primary); border: 0; cursor: pointer;
  border-radius: 16px; padding: 14px 26px; min-height: 50px; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; text-align: center;
}
.btn:hover:not(:disabled) { background: var(--primary-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.secondary:hover:not(:disabled) { background: var(--primary-soft); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 16px; min-height: 38px; font-size: 15px; border-radius: 12px; }
.btn.big { min-height: 84px; font-size: 22px; border-radius: 22px; }
.icon-btn {
  background: none; border: 0; cursor: pointer; padding: 8px; border-radius: 10px; color: var(--muted);
  display: inline-flex;
}
.icon-btn:hover { background: #eaf1f7; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.alert { border-radius: 14px; padding: 12px 16px; margin: 0 0 16px; font-weight: 500; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--primary-soft); color: #0d4a5c; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; cursor: pointer;
  font: inherit; text-align: right; color: inherit;
}
.tile:hover { border-color: var(--primary); background: #fbfeff; }
.tile .tile-title { font-size: 20px; font-weight: 700; }
.tile .tile-desc { color: var(--muted); font-size: 15px; }
.bang {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; background: #d92d20; color: #fff; font-weight: 800; font-size: 15px; margin-inline-start: 8px;
}
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.chip { background: #e8f0f7; border-radius: 999px; padding: 3px 12px; font-size: 14px; font-weight: 600; color: #334155; }
.chip.teal { background: var(--primary-soft); color: #0d4a5c; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 420px; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--border); }
th { font-weight: 700; background: #f7fafc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { width: 56px; font-weight: 700; color: var(--muted); }
td.actions { white-space: nowrap; width: 100px; }
td.center, th.center { text-align: center; }
.q-cell { unicode-bidi: plaintext; white-space: pre-wrap; }
.q-meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

.question-card { padding: 30px; }
.q-progress { color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.q-labels { margin-bottom: 14px; }
.q-text { font-size: 22px; line-height: 1.7; white-space: pre-wrap; unicode-bidi: plaintext; min-height: 140px; }
.q-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; gap: 12px; }

.notif { border: 1px solid var(--border); border-radius: 18px; padding: 16px 20px; background: #fff; margin-bottom: 12px; }
.notif.new { border-color: #f0b429; background: #fffaf0; }
.notif-head { display: flex; gap: 10px; align-items: center; font-weight: 700; margin-bottom: 4px; flex-wrap: wrap; }
.notif-meta { color: var(--muted); font-size: 15px; }
.notif-q { margin-top: 8px; padding-inline-start: 12px; border-inline-start: 3px solid var(--border); color: #344054; unicode-bidi: plaintext; }
.new-badge { background: #f0b429; color: #3b2a00; border-radius: 999px; padding: 1px 10px; font-size: 13px; font-weight: 700; }

.topic-box { border: 1px solid var(--border); border-radius: 18px; padding: 16px; margin-bottom: 12px; background: #fbfdff; }
.sub-list { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.sub-list li { display: flex; align-items: center; gap: 8px; padding-inline-start: 18px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add input { padding: 8px 14px; border-radius: 12px; }

.center-text { text-align: center; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 560px) {
  .card { padding: 20px 16px; }
  .row.stack-sm { flex-direction: column; }
  th, td { padding: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tile, .back { transition: background-color 0.12s, border-color 0.12s; }
}

/* ---- עדכון: תפריט קורס בשורות, קבוצות וציונים ---- */
.menu-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 16px; }
.title-action { display: inline-block; margin-inline-start: 16px; vertical-align: middle; font-size: 16px; font-weight: 600; }
.title-action .btn { font-size: 15px; }
.tile.danger-tile:hover { border-color: var(--danger); background: var(--danger-soft); }
.footer-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.notice { white-space: pre-line; }
.mode-switch { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.mode-switch label { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 16px; cursor: pointer; font-weight: 600; background: #fff; }
.mode-switch label.on { border-color: var(--primary); background: var(--primary-soft); }
.student-row { display: grid; grid-template-columns: minmax(140px, 1fr) 110px 2fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.student-row.no-grade { grid-template-columns: minmax(140px, 1fr) 2fr; }
.student-row:last-child { border-bottom: 0; }
.student-row input { padding: 10px 14px; }
.result-card .rc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.result-card h3 { margin: 0; font-size: 20px; }
.result-card table { margin: 6px 0 12px; }
.result-card details { margin-top: 8px; }
.result-card summary { cursor: pointer; font-weight: 600; }
.result-card ol { margin: 8px 0 0; padding-inline-start: 22px; unicode-bidi: plaintext; }
@media (max-width: 640px) {
  .student-row, .student-row.no-grade { grid-template-columns: 1fr; }
}
.alert { white-space: pre-line; }

/* ---- אקורדיון קבוצות ---- */
.acc { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.acc-item { border-bottom: 1px solid var(--border); }
.acc-item:last-child { border-bottom: 0; }
.acc-item > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px 18px; min-height: 44px; cursor: pointer; flex-wrap: wrap; }
.acc-item > summary::-webkit-details-marker { display: none; }
.acc-item > summary::before { content: "◂"; color: var(--muted); font-size: 15px; width: 16px; text-align: center; }
.acc-item[open] > summary::before { content: "▾"; }
.acc-item > summary:hover { background: #f5f9fc; }
.acc-title { font-weight: 700; font-size: 17px; }
.acc-body { padding: 6px 18px 16px; background: #fbfdff; border-top: 1px dashed var(--border); }
.acc-body .table-wrap { margin: 8px 0 12px; }
.name-list { margin: 8px 0 0; padding-inline-start: 22px; columns: 190px auto; }
.acc-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---- שאלת חובה ---- */
.chip.mandatory { background: #fde3e3; color: #9d1c1c; font-weight: 700; }
.chip.closing { background: #e6e8fb; color: #33389b; font-weight: 700; }
.chip.danger { background: var(--danger); color: #fff; font-weight: 700; }

/* ---- רשימת בדיקה כללית (V/X) ---- */
.sticky-top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-top: 6px; margin: 0 -4px; }
.checklist-header-bar { display: flex; align-items: center; gap: 10px; padding: 10px 4px 12px; border-bottom: 3px solid var(--primary); font-weight: 700; }
.checklist-text-slot { flex: 1; }
.checklist-box-slot { width: 40px; text-align: center; }
.checklist-manage-slot { width: 68px; }
.checklist-item { padding: 14px 4px; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: 0; }
.checklist-row { display: flex; align-items: center; gap: 10px; }
.checklist-text { flex: 1; font-weight: 500; }
.checklist-box { width: 40px; display: flex; justify-content: center; }
/* תיבות V/X מצוירות ידנית (לא ה-tick המובנה של הדפדפן) כדי שה-X יוצג כ-X אמיתי ולא כ-V אדום */
.checklist-box input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: 22px; height: 22px; margin: 0; cursor: pointer;
  border: 2px solid var(--border); border-radius: 6px; background: #fff;
  position: relative; display: inline-block; flex-shrink: 0;
}
.checklist-box.v input:checked { background: var(--ok); border-color: var(--ok); }
.checklist-box.x input:checked { background: var(--danger); border-color: var(--danger); }
.checklist-box.partial input:checked { background: var(--warn); border-color: var(--warn); }
.checklist-box.v input:checked::after,
.checklist-box.x input:checked::after,
.checklist-box.partial input:checked::after {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 800; line-height: 1;
}
.checklist-box.v input:checked::after { content: "✓"; }
.checklist-box.x input:checked::after { content: "✕"; }
.checklist-box.partial input:checked::after { content: "~"; }
.checklist-manage { display: flex; gap: 2px; justify-content: flex-end; }
.checklist-note { margin-top: 10px; min-height: 70px; }

/* ---- הערה אישית לשאלה בודדת (בחינת סטודנטים) ---- */
.q-note-field { margin-top: 16px; }
.q-note { min-height: 70px; }

/* ---- רובריקת ציון אוטומטי ---- */
.rubric-subtitle { margin: 18px 0 6px; font-size: 15px; }
.rubric-subtitle:first-child { margin-top: 0; }
.rubric-row { padding: 8px 4px; }
.rubric-combo-row { flex-wrap: wrap; }
.rubric-qty-select { width: auto; min-width: 90px; }

/* ---- תיבת הציון המחושב/שאושר ---- */
.grade-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grade-box input[type="number"] { transition: background-color .15s, border-color .15s; }
.grade-box.pending input[type="number"] { background: #fff6d6; border-color: #e6c232; }
.grade-box.approved input[type="number"] { background: var(--ok-soft); border-color: var(--ok); }
.grade-status { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.grade-status.pending { background: #fff6d6; color: #8a6d00; }
.grade-status.approved { background: var(--ok-soft); color: var(--ok); }

/* ---- חיווי אישור ציון ברשימת "ציונים והערות" (צהוב/ירוק) ---- */
.chip.pending-chip { background: #fff6d6; color: #8a6d00; }
.chip.approved-chip { background: var(--ok-soft); color: var(--ok); }

/* ---- פס הערות כלליות מצומצם (החלק הקבוע במסך שלפני השאלות) ---- */
.notes-bar { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; margin-bottom: 6px; }
.notes-bar-row { display: flex; align-items: flex-start; gap: 10px; }
.notes-bar-label { font-weight: 700; white-space: nowrap; padding-top: 10px; }
.notes-bar-input { flex: 1; min-height: 44px; max-height: 140px; resize: vertical; padding: 8px 12px; }
.notes-bar-students { margin-top: 6px; font-size: 14px; color: var(--muted); }

/* ---- חלון קופץ (מודאל) - למשל אישור ניקוד חלקי בסעיף חובה ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000;
}
.modal-box {
  background: var(--card); border-radius: var(--radius); padding: 24px 26px;
  max-width: 440px; width: 100%; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.25);
}
.modal-box p { margin: 0 0 14px; font-weight: 500; line-height: 1.5; }
.modal-box .row { justify-content: flex-end; }

/* ---- כפתור "+" קטן להוספת שורת בונוס "אחר" נוספת ---- */
.add-row-btn {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  border: 1.5px solid var(--primary); font-size: 18px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; flex-shrink: 0;
}
.add-row-btn:hover { background: var(--primary); color: #fff; }
