:root {
  --bg: #f2f4f3;
  --card: #ffffff;
  --line: #e2e6e4;
  --text: #1d2321;
  --muted: #6b7471;
  --primary: #1f6b5a;
  --primary-ink: #ffffff;
  --radius: 12px;

  --st-none-bg: #eef0ef;      --st-none-ink: #4b5350;
  --st-mapped-bg: #e2f1e6;    --st-mapped-ink: #24613a;
  --st-active-bg: #e3ebf7;    --st-active-ink: #24477a;
  --st-soon-bg: #fcecd3;      --st-soon-ink: #9a5a06;
  --st-late-bg: #fbe2e0;      --st-late-ink: #b3261e;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "Heebo", "Rubik", "Segoe UI", "Arial Hebrew", Arial, sans-serif; font-size: 15px; line-height: 1.5; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* header */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.top .sub { color: var(--muted); margin: 2px 0 6px; }
.badge-demo { display: inline-block; background: #fdf1d8; color: #8a5a00; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { font-size: 13px; color: var(--muted); }

/* segmented tabs */
.tabs { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--primary); color: var(--primary-ink); }

/* generic */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.btn { border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 700; padding: 9px 20px; border-radius: 10px; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.link { border: 0; background: none; color: var(--muted); padding: 4px 6px; font-weight: 500; text-decoration: underline; }
label.f { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=url], input[type=date], textarea, select {
  width: 100%; font: inherit; color: inherit; background: #f4f6f5; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input:disabled, textarea:disabled { color: var(--muted); }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.err { color: var(--st-late-ink); font-size: 14px; margin-top: 10px; }
.note { background: #f4f6f5; border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--muted); }

/* login */
.login { max-width: 360px; margin: 40px auto 0; }
.login .btn { width: 100%; margin-top: 18px; }
.demo-users { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; color: var(--muted); }
.demo-users code { background: #eef0ef; border-radius: 6px; padding: 1px 6px; direction: ltr; unicode-bidi: isolate; }

/* class view */
.row-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 14px; gap: 12px; }
.class-pick { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.class-pick select { width: auto; min-width: 90px; background: var(--card); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.stat b { display: block; font-size: 28px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.soon b { color: var(--st-soon-ink); }
.stat.late b { color: var(--st-late-ink); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.grid-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 640px; table-layout: fixed; }
table.grid th:first-child { width: 130px; }
table.grid th:first-child, table.grid td.name { position: sticky; inset-inline-start: 0; background: var(--card); z-index: 1; }
table.grid th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 600; padding: 6px 6px 10px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid td.name { font-weight: 700; white-space: nowrap; padding-inline-end: 14px; }
.cell { display: block; width: 100%; border: 0; border-radius: 8px; padding: 7px 10px; font: inherit; text-align: center; cursor: pointer; min-height: 40px; }
.cell .l1 { display: block; font-weight: 600; font-size: 13px; }
.cell .l2 { display: block; font-size: 11px; opacity: .85; }
.cell[disabled] { cursor: default; }
.st-none { background: var(--st-none-bg); color: var(--st-none-ink); }
.st-mapped_only { background: var(--st-mapped-bg); color: var(--st-mapped-ink); }
.st-active { background: var(--st-active-bg); color: var(--st-active-ink); }
.st-due_soon { background: var(--st-soon-bg); color: var(--st-soon-ink); }
.st-overdue { background: var(--st-late-bg); color: var(--st-late-ink); }
.st-locked { background: transparent; color: #a9b0ad; border: 1px dashed var(--line); }
.foot { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* entry view */
.entry { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
/* student column (right side in RTL): stays in view and scrolls on its own; the mapping takes the rest */
.students { position: sticky; top: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 24px); padding: 14px 12px; }
.stu-list { overflow-y: auto; min-height: 0; flex: 1; margin: 0 -4px; padding: 0 4px; overscroll-behavior: contain; }
.stu-filter { margin-bottom: 10px; padding: 7px 10px; font-size: 14px; }
.students h2 { margin-bottom: 10px; }
.students button { display: flex; justify-content: space-between; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; font: inherit; cursor: pointer; text-align: start; }
.students button.on { background: #e7f3ee; border-color: #8cc2b0; }
.students .cnt { color: var(--muted); font-size: 12px; }
.stu-list button[hidden] { display: none; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.pills button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 14px; font: inherit; cursor: pointer; }
.pills button.on { background: var(--text); color: #fff; border-color: var(--text); }
.pills .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #2e8b57; margin-inline-start: 6px; vertical-align: 2px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 16px 0 6px; }
.sec-title i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
fieldset.box { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 14px; margin: 16px 0 0; }
fieldset.box legend { font-weight: 700; padding: 0 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.res { display: flex; align-items: center; gap: 8px; background: #f4f6f5; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; margin-top: 8px; }
.res .kind { font-size: 11px; background: #e3ebf7; color: var(--st-active-ink); border-radius: 6px; padding: 1px 6px; }
.res a, .res .t { flex: 1; color: var(--st-active-ink); cursor: pointer; text-decoration: underline; overflow-wrap: anywhere; }
.res .x { border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; line-height: 1; }
.add-link { display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 8px; margin-top: 10px; }
.add-file { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.save-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }

/* parent view */
.child-head { margin-bottom: 14px; }
.subj-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.subj-card h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.subj-card p { margin: 0 0 8px; }
.subj-card .lbl { font-weight: 700; font-size: 13px; color: var(--muted); display: block; }

/* admin (ניהול) */
.sub-tabs { margin: 0 0 14px; }
.tbl-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 600; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td.name { font-weight: 700; white-space: nowrap; }
table.list td.num { text-align: center; color: var(--muted); }
table.list td.acts { white-space: nowrap; text-align: end; }
table.list select { width: 100%; min-width: 84px; padding: 6px 4px; background: var(--card); font-size: 14px; }
table.list td.acts .btn.link { padding: 2px 4px; }
table.list code, .cred code { direction: ltr; unicode-bidi: isolate; background: #eef0ef; border-radius: 6px; padding: 1px 6px; }
.btn.link.danger { color: var(--st-late-ink); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form > div { flex: 1 1 180px; }
.inline-form .btn { margin-bottom: 1px; }
.cred { border-color: #8cc2b0; background: #f3faf7; margin-bottom: 16px; }
.cred-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: center; margin: 8px 0; }
.cred-grid code { font-size: 16px; justify-self: start; }
.kid { display: inline-flex; align-items: center; gap: 4px; background: #e7f3ee; border-radius: 999px; padding: 2px 4px 2px 10px; margin: 2px 0 2px 6px; font-size: 13px; }
.kid .x { border: 0; background: none; font-size: 16px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
select.add-kid { width: auto; min-width: 0; font-size: 13px; padding: 3px 6px; }

@media (max-width: 800px) {
  .page { padding: 16px 12px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  table.grid { min-width: 560px; }
  table.grid th:first-child { width: 96px; }
  table.grid td.name { white-space: normal; padding-inline-end: 8px; }
  .entry { grid-template-columns: 200px minmax(0, 1fr); gap: 12px; }
  .students button { padding: 8px 10px; }
  .two, .add-link, .subj-cards { grid-template-columns: 1fr; }
}

/* student import */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.imp-pick { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.imp-pick label.btn { display: inline-block; }
label.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 14px; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.imp-cols { margin-bottom: 4px; }
.imp-preview { max-height: 420px; overflow-y: auto; }
.imp-preview thead th { position: sticky; top: 0; background: var(--card); }
.imp-skip td.name { color: var(--muted); text-decoration: line-through; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.tag.ok { background: var(--st-mapped-bg); color: var(--st-mapped-ink); }
.tag.muted { background: var(--st-none-bg); color: var(--st-none-ink); }
.tag.warn { background: var(--st-soon-bg); color: var(--st-soon-ink); }
.warn-text { color: var(--st-soon-ink); font-weight: 600; }
.imp-pick:focus-within label.btn { outline: 2px solid var(--primary); outline-offset: 2px; }

/* student profile logins */
td.login-cell { white-space: nowrap; }
td.login-cell code { margin-inline-end: 4px; }
.slips { display: none; }
@media print {
  body.print-slips * { visibility: hidden; }
  body.print-slips .slips, body.print-slips .slips * { visibility: visible; }
  body.print-slips .slips { display: grid; grid-template-columns: 1fr 1fr; gap: 0; position: absolute; inset: 0 0 auto 0; direction: rtl; }
  .slip { border: 1px dashed #888; padding: 10px 14px; break-inside: avoid; font-size: 13px; color: #000; }
  .slip-school { font-size: 11px; color: #555; }
  .slip-name { font-weight: 700; font-size: 15px; margin: 2px 0 6px; }
  .slip-row { display: flex; justify-content: space-between; gap: 8px; }
  .slip-row code { direction: ltr; unicode-bidi: isolate; font-size: 14px; font-weight: 700; background: none; }
  .slip-note { font-size: 10px; color: #555; margin-top: 6px; }
}

/* mapping history */
.save-row .hist-btn { margin-inline-start: auto; }
.hist { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.hist h3 { margin-bottom: 8px; }
.hist ol { list-style: none; margin: 0; padding: 0; }
.hist li { border-inline-start: 3px solid var(--line); padding: 6px 12px 8px; margin-bottom: 8px; }
.hist-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 4px; }
.hist-field { margin: 4px 0; font-size: 14px; }
.hist-field .lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.hist del { background: var(--st-late-bg); color: var(--st-late-ink); text-decoration: line-through; padding: 0 3px; border-radius: 4px; }
.hist ins { background: var(--st-mapped-bg); color: var(--st-mapped-ink); text-decoration: none; padding: 0 3px; border-radius: 4px; }
.hist .arrow { color: var(--muted); margin: 0 4px; }
.hist-res { font-size: 14px; }

/* phones: no room for two columns, so the student list becomes a scrolling strip above the mapping */
@media (max-width: 600px) {
  .entry { grid-template-columns: minmax(0, 1fr); }
  .students { position: static; max-height: none; padding: 10px; }
  .students h2, .stu-filter { display: none; }
  .stu-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; }
  .students button { width: auto; white-space: nowrap; gap: 10px; margin: 0; }
}

/* adding students one by one */
.manual-tbl td { vertical-align: middle; }
.manual-tbl input[type=text] { min-width: 180px; }
.manual-tbl select { min-width: 110px; }
.manual-tbl .x { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 8px; }
.manual-tbl .x:disabled { opacity: .3; cursor: default; }
.manual-tbl td.warn-text { font-size: 13px; }

/* שכבה / תלתון / מקצוע pickers, groups and teachers screens */
.filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.filters .class-pick select { min-width: 120px; }
td.name .who-sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.groups-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .groups-grid { grid-template-columns: 1fr; } }
td.center { text-align: center; }
td.center input[type=checkbox] { width: auto; }
.asg-cell { min-width: 230px; }
.asg-cell .kid { margin-bottom: 4px; }
.add-asg { display: inline-flex; gap: 4px; margin-top: 2px; }
.add-asg select { width: auto; min-width: 0; font-size: 13px; padding: 3px 6px; }
.teachers-tbl select[data-tsub] { min-width: 90px; }

/* in-page dialogs (web/dialog.js) */
.dlg-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 25, .35); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 12px 12px; z-index: 50; overflow-y: auto; }
.dlg { background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); width: min(440px, 100%); padding: 18px 20px 16px; }
.dlg.wide { width: min(720px, 100%); }
.dlg h3 { margin: 0 0 8px; font-size: 17px; }
.dlg-text { margin: 4px 0 6px; line-height: 1.6; }
.dlg-body label.f:first-child { margin-top: 4px; }
.dlg-err:empty { display: none; }
.dlg-actions { display: flex; gap: 10px; margin-top: 16px; }
.dlg .checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 12px; margin: 6px 0; }
.dlg .checks label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.dlg .checks input { width: auto; margin: 0; }
.dlg .pick-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-top: 8px; }
.dlg .pick-list label { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; cursor: pointer; }
.dlg .pick-list input { width: auto; margin: 0; }
.dlg .pick-list .muted { font-size: 12px; }
.dlg .two-col { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; align-items: center; }
.dlg .two-col select { width: 100%; }
.btn.danger { background: var(--st-late-ink); border-color: var(--st-late-ink); color: #fff; }
.dlg .pick-list label[hidden] { display: none; }
.dlg-sub { margin: 16px 0 6px; font-size: 14px; }
.chips-cell { min-width: 160px; }
.chip-sm { display: inline-block; background: #eef3f1; border-radius: 999px; padding: 1px 9px; margin: 2px 0 2px 4px; font-size: 12.5px; white-space: nowrap; }
.chip-sm b { font-weight: 600; }
