/* תוספות של האסיפה מעל glass.css. צבע חדש = משתנה כאן, לא hex בתוך קומפוננטה. */

/* סולם הדירוג: נבדק בכלי של dataviz (עיוורון צבעים + ניגודיות). תמיד עם טקסט על התא. */
:root, :root[data-theme="dark"] {
  --r1: #e53950; --r2: #c08a20; --r3: #2d9ac4; --r4: #6b66ee;
  --r1-ink: #fff; --r2-ink: #1b1406; --r3-ink: #04161f; --r4-ink: #fff;
  --risk: #ff5a76; --watch: #ffa463; --okc: #5b9cf5;
  --field: rgba(255, 255, 255, .07);
}
:root[data-theme="light"] {
  --r1: #d13b40; --r2: #ec9a4b; --r3: #4fa8d8; --r4: #1f5fae;
  --r1-ink: #fff; --r2-ink: #2a1703; --r3-ink: #04161f; --r4-ink: #fff;
  --risk: #c62a3a; --watch: #b85c0c; --okc: #1f5fae;
  --field: rgba(255, 255, 255, .7);
}
.r-0-55 { --rc: var(--r1); --ri: var(--r1-ink); }
.r-55-70 { --rc: var(--r2); --ri: var(--r2-ink); }
.r-70-85 { --rc: var(--r3); --ri: var(--r3-ink); }
.r-85-100 { --rc: var(--r4); --ri: var(--r4-ink); }

body { font-family: "Heebo", "Inter", -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif; }
.app { max-width: 1440px; margin-inline: auto; }
.topbar { justify-content: space-between; }
.topbar-title { font-weight: 600; color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.rail-label { display: none; }
.rail-logo { color: #fff; }
a.tool { display: grid; }
.h1 small { font-size: 15px; color: var(--text-2); font-weight: 500; margin-inline-start: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-3 .span-2 { grid-column: span 2; }
.grid-3 .span-3 { grid-column: 1 / -1; }
.empty { padding: 28px 8px; text-align: center; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-2); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-danger { color: #fff; border-color: transparent; background: linear-gradient(180deg, color-mix(in srgb, var(--red) 80%, white), var(--red)); }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--glass-raised); }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--text-2); transition: background .2s, color .2s; }
.icon-btn:hover { background: var(--glass-raised); color: var(--text); }
.icon-btn svg.i { width: 16px; height: 16px; }
.wa { --c: #25d366; }
.btn.wa { color: #fff; border-color: transparent; background: linear-gradient(180deg, #3ee07f, #1fb457); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 12px rgba(0, 0, 0, .18); }

/* שדות */
.field, .app select, .app input[type="text"], .app input[type="tel"], .app input[type="password"], .app input:not([type]), .app textarea, .sheet-card input, .login-card input {
  font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 8px 12px; outline: none; min-width: 0; max-width: 100%;
  box-shadow: inset 0 1px 0 var(--stroke-hi); transition: border-color .2s, box-shadow .2s;
}
.app select { padding-inline-end: 28px; }
.app select option { background: var(--bg); color: var(--text); }
.app textarea { width: 100%; min-height: 84px; resize: vertical; line-height: 1.55; }
.field:focus, .app select:focus, .app input:focus, .app textarea:focus, .login-card input:focus { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.app textarea:disabled, .app input:disabled { opacity: .6; }
label.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-block-end: 6px; }

/* אי: צבעי סוג הודעה */
.island .island-err { background: var(--red); color: #fff; }
.island .island-info { background: var(--accent); color: #fff; }
.island .island-text { overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }

/* חלון אישור / גיליון */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .25s ease both; }
.sheet-card { border-radius: 26px; padding: 22px; width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: pop .45s var(--spring) both; }
.sheet-wide { width: min(560px, 100%); }
:root[data-glass] .sheet-card.glass { background: color-mix(in srgb, var(--bg) 72%, transparent); }
.sheet-q { font-size: 15px; font-weight: 600; text-align: center; margin: 4px 0 18px; line-height: 1.5; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }

/* ערכות מוכנות */
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.preset-thumb { width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; position: relative; overflow: hidden; border: 2px solid transparent; transition: border-color .25s; }
.preset-thumb i { position: absolute; inset-inline-start: 12%; inset-block-end: 16%; width: 34%; height: 18%; border-radius: 99px; }
.preset-thumb i.l2 { inset-block-end: auto; inset-block-start: 16%; width: 60%; height: 22%; background: rgba(255, 255, 255, .22); border-radius: 6px; }
.preset[aria-pressed="true"] .preset-thumb { border-color: var(--accent); }
.preset[aria-pressed="true"] { color: var(--text); }

/* תגי מצב */
.lvl { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 7px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.lvl::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.lvl-risk { color: var(--risk); background: color-mix(in srgb, var(--risk) 15%, transparent); }
.lvl-watch { color: var(--watch); background: color-mix(in srgb, var(--watch) 17%, transparent); }
.lvl-ok { color: var(--okc); background: color-mix(in srgb, var(--okc) 14%, transparent); }
.lvl-none { color: var(--text-3); background: var(--track); }

/* תא דירוג */
.rc { display: inline-grid; place-items: center; min-width: 52px; height: 26px; padding: 0 6px; border-radius: 8px; font-size: 11.5px; font-weight: 700; direction: ltr; background: var(--rc, var(--track)); color: var(--ri, var(--text-3)); }
.rc.empty-cell { background: transparent; border: 1px dashed var(--divider); }

/* טבלאות זכוכית */
.tbl-wrap { overflow-x: auto; margin-inline: -4px; padding-inline: 4px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { font-size: 11.5px; color: var(--text-2); font-weight: 600; text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .2s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.tbl .c { text-align: center; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--text-2); }
.avatar { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 45%, var(--glass-raised)), var(--glass-raised)); color: var(--text); }
img.avatar { object-fit: cover; }

/* טבעת */
.ring { position: relative; flex: none; }
.ring-arc { transition: stroke-dashoffset 1s var(--spring); }
.ring-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-mid b { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.ring-mid b small { font-size: 13px; color: var(--text-2); font-weight: 600; }
.ring-mid span { font-size: 11px; color: var(--text-2); }

/* התפלגות: פס מוערם עם רווח 2px */
.dist-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 12px; padding: 7px 0; }
.dist-row > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.stackbar { display: flex; gap: 2px; height: 26px; border-radius: 8px; overflow: hidden; background: var(--track); }
.stackbar > i { background: var(--rc); color: var(--ri); font-style: normal; font-size: 11px; font-weight: 700; display: grid; place-items: center; min-width: 0; overflow: hidden; white-space: nowrap; transition: flex-grow .6s var(--spring); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--rc); }

/* עמודות השוואה (כיתות) */
.hbars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 54px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar b { font-weight: 600; }
.hbar .track { height: 22px; border-radius: 6px; background: var(--track); overflow: hidden; }
.hbar .track i { display: block; height: 100%; width: var(--w); border-radius: 0 6px 6px 0; background: linear-gradient(270deg, color-mix(in srgb, var(--c, var(--accent)) 90%, white 10%), color-mix(in srgb, var(--c, var(--accent)) 55%, transparent)); transition: width .8s var(--spring); }
[dir="rtl"] .hbar .track i { border-radius: 6px 0 0 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--accent)) 90%, white 10%), color-mix(in srgb, var(--c, var(--accent)) 55%, transparent)); margin-inline-start: 0; }
.hbar .val { text-align: end; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* מפת חום */
.heat { display: grid; gap: 2px; font-size: 11px; }
.heat .h { color: var(--text-2); font-weight: 600; display: grid; place-items: center; text-align: center; padding: 4px 2px; line-height: 1.2; min-height: 34px; }
.heat .rowh { color: var(--text); font-weight: 700; display: flex; align-items: center; padding-inline-end: 6px; }
.heat .cell { border-radius: 6px; height: 34px; display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--rc, var(--track)); color: var(--ri, var(--text-3)); cursor: default; }
.heat .cell.na { background: transparent; border: 1px dashed var(--divider); color: var(--text-3); }

/* כרטיסי KPI */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { border-radius: var(--r-chip); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-label svg.i { width: 14px; height: 14px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-value small { font-size: 13px; color: var(--text-2); font-weight: 500; margin-inline-start: 3px; }
.kpi-foot { font-size: 11.5px; color: var(--text-3); }
.kpi.is-risk .kpi-value { color: var(--risk); }
.kpi.is-watch .kpi-value { color: var(--watch); }

/* CRM: רשימת מורים ותלמידים */
.crm-list { display: flex; flex-direction: column; }
.crm-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(120px, 1fr) minmax(130px, .9fr) auto; gap: 14px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--divider); }
.crm-row:last-child { border-bottom: 0; }
.crm-row .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.crm-row .acts { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.crm-row details { grid-column: 1 / -1; }
.crm-row details summary { cursor: pointer; font-size: 12px; color: var(--accent-text); font-weight: 600; list-style: none; }
.crm-row details summary::-webkit-details-marker { display: none; }
.mini-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 8px; }
.mini-group { border-radius: 12px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.prog-cell { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }
.prog-cell b { color: var(--text); font-weight: 700; }
.phone { width: 130px; direction: ltr; text-align: end; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: transform .25s var(--spring), background .2s; }
a.tile:hover { transform: translateY(-2px); background: var(--glass-hover); }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-title { font-size: 17px; font-weight: 700; }

/* כרטיס תלמיד (מגירה) */
.drawer { position: fixed; inset-block: 12px; inset-inline-end: 12px; width: min(560px, calc(100vw - 24px)); z-index: 55; border-radius: 26px; padding: 18px; overflow: auto; animation: slide .5s var(--spring) both; }
:root[data-glass] .drawer.glass { background: color-mix(in srgb, var(--bg) 78%, transparent); }
@keyframes slide { from { opacity: 0; transform: translateX(-24px); } }
.drawer-backdrop { position: fixed; inset: 0; z-index: 54; background: rgba(0, 0, 0, .25); animation: fade .25s both; }

/* גריד הסיכום (מקצועות x תחומים) */
.sgrid { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.sgrid th { font-weight: 600; color: var(--text-2); padding: 4px; text-align: center; line-height: 1.25; }
.sgrid th.side { text-align: start; width: 70px; color: var(--text-2); }
.sgrid th .t { display: block; font-weight: 500; color: var(--text-3); font-size: 10.5px; }
.sgrid td { text-align: center; padding: 0; }
.sgrid td .rc { width: 100%; min-width: 46px; }
.sgrid td.cm { font-size: 11.5px; color: var(--text-2); text-align: start; vertical-align: top; padding: 4px; white-space: pre-wrap; line-height: 1.4; }

/* מילוי */
.fill-card { border-radius: var(--r-card); padding: 16px; display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px 14px; transition: box-shadow .3s; }
.fill-card.complete { box-shadow: inset 0 1px 0 var(--stroke-hi), var(--shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.fill-card .name { font-size: 16px; font-weight: 700; }
.fill-card .fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.fill-card .comment { grid-column: 1 / -1; }
.fill-card textarea { min-height: 56px; }
.rseg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: 14px; background: var(--glass); border: 1px solid var(--stroke); }
.rseg label { position: relative; }
.rseg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.rseg span { display: grid; place-items: center; height: 36px; border-radius: 11px; font-size: 12.5px; font-weight: 700; color: var(--text-2); direction: ltr; transition: background .3s var(--spring), color .2s, transform .2s var(--spring); }
.rseg label:hover span { background: var(--glass-raised); color: var(--text); }
.rseg input:checked + span { background: var(--rc); color: var(--ri); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 6px rgba(0, 0, 0, .18); }
.rseg input:active + span { transform: scale(.95); }
.rseg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.saved-dot { font-size: 11.5px; color: var(--green); font-weight: 600; opacity: 0; transition: opacity .3s; }
.saved-dot.on { opacity: 1; }
.sticky-progress { position: sticky; inset-block-start: 10px; z-index: 20; border-radius: var(--r-pill); padding: 8px 10px 8px 16px; padding-inline: 16px 10px; display: flex; align-items: center; gap: 12px; }

/* דף כניסה */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); border-radius: 28px; padding: 28px; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 75%, white), var(--accent)); box-shadow: 0 10px 24px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255,255,255,.35); }
.login-logo svg.i { width: 32px; height: 32px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .crm-row { grid-template-columns: minmax(0, 1fr) auto; }
  .crm-row .hide-sm { display: none; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fill-card .fields { grid-template-columns: minmax(0, 1fr); }
  .topbar-title { display: none; }
}
@media (max-width: 640px) {
  .rail-item { width: 40px; height: 40px; }
  .topbar { justify-content: flex-end; margin-block-start: 44px; }
  .drawer { inset: 8px; width: auto; }
}

/* טעינה */
.loader { min-height: 50vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.loader i { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--accent); animation: spin .9s linear infinite; }

/* סרגל מורחב */
.rail-toggle { color: var(--text-3); }
.rail-brand { display: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
@media (min-width: 641px) {
  .app { transition: grid-template-columns var(--dur) var(--spring); }
  .app.rail-open { grid-template-columns: 216px minmax(0, 1fr); }
  .rail-open .rail { align-items: stretch; padding: 12px 10px; border-radius: 28px; }
  .rail-open .rail-head { display: flex; align-items: center; gap: 10px; padding-inline: 4px; margin-block-end: 10px; }
  .rail-open .rail-head .rail-logo { margin: 0; }
  .rail-open .rail-brand { display: block; }
  .rail-open .rail-item { width: auto; height: 42px; border-radius: 14px; display: flex; align-items: center; gap: 12px; padding-inline: 12px; justify-content: flex-start; }
  .rail-open .rail-label { display: inline; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
  .rail-open .rail-foot { display: flex; align-items: center; gap: 10px; padding-inline: 6px; }
  .rail-open .rail-foot .rail-toggle { margin-inline-start: auto; }
  .rail-open .rail-toggle svg { scale: -1 1; }
  [dir="rtl"] .rail-open .rail-toggle svg { scale: -1 1; }
}
.rail-head, .rail-foot { display: contents; }
.rail-foot .who-name { display: none; }
.rail-open .rail-foot .who-name { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
[dir="rtl"] .rail-toggle svg { scale: 1 1; }
@media (max-width: 640px) { .rail-toggle, .rail-foot .avatar, .who-name, .rail-head .rail-brand { display: none !important; } }
/* כניסת מסך בלי טשטוש: blur על משטח עם זכוכית כבד מדי ונתקע במחשבים חלשים */
.view { animation: view-in .35s var(--spring) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
