/* =========================================================
   البرامج · ALBARAMEJ — dark theme
   Grainy deep-blue background, matte graphite surfaces,
   electric coral for the things that matter.
   ========================================================= */

:root {
  color-scheme: dark;

  /* Base */
  --bg: #0f1522;            /* deep navy, under the grain */
  --bg-2: #141c2e;
  --surface: #1b2029;       /* matte graphite cards */
  --surface-2: #222833;     /* inputs, table heads, hover */
  --surface-3: #2a313d;     /* raised / pressed */
  --border: #2c333f;
  --border-strong: #3a4250;
  --text: #e6e9ef;          /* soft white, never pure */
  --text-2: #b9c0cc;
  --muted: #8a93a3;

  /* Accent: electric coral */
  --accent: #ff6b57;
  --accent-strong: #ff8572;
  --accent-ink: #1a0f0d;    /* text on coral */
  --accent-soft: rgba(255, 107, 87, 0.14);
  --accent-soft-2: rgba(255, 107, 87, 0.22);
  --accent-glow: 0 6px 22px rgba(255, 107, 87, 0.28);

  /* Status colours (names kept from the first design) */
  --sage: #4fc3a1;          /* success: present / done / positive */
  --sage-dark: #7fdcbf;     /* success text */
  --sage-soft: rgba(79, 195, 161, 0.14);
  --sky: #6aa5ff;           /* info / one-time */
  --sky-soft: rgba(106, 165, 255, 0.14);
  --sky-text: #9cc2ff;
  --sand: #e8b264;          /* waiting / partial / due soon */
  --sand-soft: rgba(232, 178, 100, 0.14);
  --sand-text: #f2c98a;
  --sand-tint: rgba(232, 178, 100, 0.06);
  --clay: #f0565f;          /* danger: absent / concern / delete */
  --clay-strong: #ff6f77;
  --clay-soft: rgba(240, 86, 95, 0.15);
  --clay-tint: rgba(240, 86, 95, 0.06);
  --today-bg: rgba(255, 107, 87, 0.06);

  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px rgba(0, 0, 0, 0.38);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "DM Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

.muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.right { text-align: end; }
.hidden { display: none !important; }

button, input, select { font: inherit; color: inherit; }

/* ---------- Loading ---------- */
.loading-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 100;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--sage-soft);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand--center { justify-content: center; margin-bottom: 28px; }
.brand__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), var(--sky));
}
.brand__name { font-weight: 700; letter-spacing: -0.01em; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, #e3ece5 0, transparent 45%),
    radial-gradient(circle at 85% 80%, #e2ebf1 0, transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 22px;
  padding: 40px 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise .5s var(--ease);
}
.login-card h1 { margin-bottom: 4px; }
.login-card .form { margin-top: 24px; text-align: start; }
.login-card .tiny { margin-top: 18px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form--inline {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}
.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field--wide { grid-column: span 2; }
.form__actions { display: flex; gap: 8px; }

.field input, .field select, .input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field select:focus, .input:focus {
  outline: none;
  border-color: var(--sage);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--sage-soft);
}
.form-error { color: var(--clay); font-size: 0.85rem; min-height: 1.2em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, transform .1s, border-color .2s, color .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn--full { width: 100%; }
.btn--primary { background: var(--sage); color: #fff; }
.btn--primary:hover { background: var(--sage-dark); }
.btn--soft { background: var(--sage-soft); color: var(--sage-dark); }
.btn--soft:hover { background: var(--accent-soft-2); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--clay); color: #fff; }
.btn--danger:hover { background: var(--clay-strong); }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font-size: 0.85rem;
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn--danger:hover { background: var(--clay-soft); color: var(--clay); }

.link-btn {
  margin-top: 14px;
  background: none; border: none; cursor: pointer;
  color: var(--sage-dark); font-size: 0.9rem;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 26px 18px;
  display: flex; flex-direction: column; gap: 32px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 10px; }

.nav { display: grid; gap: 4px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer; text-align: start;
  transition: background .2s, color .2s;
}
.nav__item svg {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.active { background: var(--sage-soft); color: var(--sage-dark); font-weight: 500; }

.sidebar__footer { margin-top: auto; display: grid; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--sky-soft); color: var(--sky);
  font-weight: 600; font-size: 0.85rem; text-transform: uppercase;
}
.user-chip__email {
  font-size: 0.85rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main {
  flex: 1; min-width: 0;
  padding: 40px clamp(20px, 4vw, 56px);
  max-width: 1200px;
}

.view { display: none; animation: fade .35s var(--ease); }
.view.active { display: grid; gap: 20px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view__header { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card--flush { padding: 0; overflow: hidden; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .input { width: auto; min-width: 160px; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: grid; gap: 6px;
}
.stat__label { font-size: 0.85rem; color: var(--muted); }
.stat__value { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; }
.stat:nth-child(1) .stat__value { color: var(--sage-dark); }
.stat:nth-child(2) .stat__value { color: var(--sky); }
.stat:nth-child(3) .stat__value { color: var(--sand); }
.stat:nth-child(4) .stat__value { color: var(--clay); }

.simple-list { list-style: none; display: grid; gap: 2px; }
.simple-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.simple-list li:last-child { border-bottom: none; }
.simple-list .muted { white-space: nowrap; font-size: 0.85rem; }

.empty { color: var(--muted); font-size: 0.9rem; padding: 24px; text-align: center; }
.simple-list .empty { padding: 12px 0; justify-content: center; border: none; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: start; font-weight: 500; font-size: 0.8rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 14px 22px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 22px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }

.tag {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 500;
  background: var(--sage-soft); color: var(--sage-dark);
}

/* ---------- Attendance ---------- */
.attendance-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.attendance-summary .pill { padding: 6px 14px; border-radius: 999px; font-size: 0.85rem; }

.attendance-list { list-style: none; }
.attendance-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}
.attendance-list li:last-child { border-bottom: none; }
.attendance-list .who { display: grid; min-width: 0; }
.attendance-list .who span:last-child { font-size: 0.8rem; color: var(--muted); }

.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 9px;
  font-size: 0.85rem; color: var(--muted);
  transition: background .2s, color .2s;
}
.seg button:hover { color: var(--text); }
.seg button.on-present { background: var(--sage-soft); color: var(--sage-dark); font-weight: 500; }
.seg button.on-late    { background: var(--sand-soft); color: var(--sand-text); font-weight: 500; }
.seg button.on-absent  { background: var(--clay-soft); color: var(--clay); font-weight: 500; }

.pill--present { background: var(--sage-soft); color: var(--sage-dark); }
.pill--late    { background: var(--sand-soft); color: var(--sand-text); }
.pill--absent  { background: var(--clay-soft); color: var(--clay); }
.pill--unmarked{ background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Homework ---------- */
.homework-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.hw-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid; gap: 12px;
  align-content: start;
}
.hw-card__top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.hw-card__title { font-weight: 600; }
.hw-card__meta { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.hw-card__desc { font-size: 0.9rem; color: var(--muted); }

/* Links on an assignment */
.hw-links { display: flex; flex-wrap: wrap; gap: 6px; }
.hw-link {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.85rem; color: inherit; text-decoration: none;
}
.hw-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-link:hover { background: var(--surface-2); text-decoration: none; }
.hw-link.yt { border-color: rgba(255, 92, 92, 0.4); }
.hw-link.yt span:first-child { color: #ff6b6b; }

/* Add/edit form: daily preview and link rows */
.field--full { grid-column: 1 / -1; }
.hw-links-edit { display: grid; gap: 8px; }
.hw-links-edit:empty { display: none; }
.hw-link-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; align-items: center; }
.hw-add-link { justify-self: start; }
@media (max-width: 640px) {
  .hw-link-row { grid-template-columns: 1fr auto; }
  .hw-link-row .hw-link-name { grid-column: 1; }
}
.due-soon { color: var(--sand); font-weight: 500; }
.overdue { color: var(--clay); font-weight: 500; }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--sage); border-radius: 999px; transition: width .4s var(--ease); }

details.hw-students summary {
  cursor: pointer; font-size: 0.85rem; color: var(--sage-dark);
  list-style: none; user-select: none;
}
details.hw-students summary::-webkit-details-marker { display: none; }
details.hw-students summary::before { content: "▸ "; }
details.hw-students[open] summary::before { content: "▾ "; }
.hw-students ul { list-style: none; margin-top: 10px; display: grid; gap: 4px; }
.hw-students li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.88rem; padding: 4px 0;
}
.hw-students .seg button { padding: 4px 10px; font-size: 0.78rem; }

/* ---------- Behavior ---------- */
.behavior-list { list-style: none; display: grid; gap: 10px; }
.behavior-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex; gap: 14px; align-items: start;
  border-inline-start: 4px solid var(--sage);
}
.behavior-item.concern { border-inline-start-color: var(--clay); }
.behavior-item.neutral { border-inline-start-color: var(--sky); }
.behavior-item__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.behavior-item__head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.behavior-item__head strong { font-weight: 600; }
.behavior-item__head .muted { font-size: 0.82rem; }
.behavior-item p { font-size: 0.92rem; }
.behavior-item .by { font-size: 0.78rem; color: var(--muted); }

/* Sub-comments under a behavior note */
.replies {
  list-style: none; display: grid; gap: 6px; margin-top: 8px;
  padding-inline-start: 12px; border-inline-start: 2px solid var(--border);
}
.reply { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.reply__body { display: grid; gap: 1px; min-width: 0; }
.reply__body p { font-size: 0.88rem; overflow-wrap: anywhere; }
.reply__body .byline b { font-weight: 500; }
.reply__delete { padding: 2px 6px; font-size: 0.75rem; }
.reply-actions { margin-top: 6px; }
.reply-toggle { margin: 0; font-size: 0.82rem; }
.reply-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.reply-form .input { flex: 1; min-width: 200px; padding: 8px 12px; }
.reply-form .btn { padding: 8px 14px; font-size: 0.85rem; }
.history-list .replies { margin-top: 6px; }

/* Homework: card opens its own page */
.hw-card.is-clickable { cursor: pointer; transition: box-shadow .2s, transform .15s var(--ease); }
.hw-card.is-clickable:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.2), 0 14px 30px rgba(0,0,0,.35); }
.hw-card.is-clickable:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--sage-soft), var(--shadow); }
.hw-card__open { font-size: 0.82rem; color: var(--sage-dark); font-weight: 500; }

/* Homework page: one row per student */
.hw-detail { display: grid; gap: 12px; }
.hw-detail p { white-space: pre-line; }
.hw-track { list-style: none; }
.hw-track li { padding: 12px 22px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.hw-track li:last-child { border-bottom: none; }
.hw-track li.is-partial { background: var(--sand-tint); }
.hw-track__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hw-track__name { font-weight: 500; }
.hw-track__note .input { width: 100%; }
.hw-track__note .muted { font-size: 0.88rem; }
.hw-partial-note { display: block; font-size: 0.8rem; color: var(--sand-text); margin-top: 2px; }
.status-pill.partial { background: var(--sand-soft); color: var(--sand-text); }
.actions { display: flex; gap: 2px; flex-shrink: 0; }

.tag--positive { background: var(--sage-soft); color: var(--sage-dark); }
.tag--neutral  { background: var(--sky-soft); color: var(--sky-text); }
.tag--concern  { background: var(--clay-soft); color: var(--clay); }

/* ---------- Roles ---------- */
.user-chip__text { display: grid; min-width: 0; }
.role-badge {
  justify-self: start;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--sage-dark);
}
.role-badge.manager { color: var(--sand-text); }
.tag--manager { background: var(--sand-soft); color: var(--sand-text); }
.tag--teacher { background: var(--sky-soft); color: var(--sky-text); }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }

.notice {
  background: var(--sand-soft); color: var(--sand-text);
  border-radius: var(--radius-sm);
  padding: 14px 18px; font-size: 0.92rem;
}
.scope-line { font-size: 0.9rem; margin-top: -8px; }
.scope-line:empty { display: none; }
.form-hint { margin-top: 14px; }

/* ---------- Attribution ---------- */
.byline { font-size: 0.78rem; color: var(--muted); }
.byline b { font-weight: 500; color: var(--text-2); }
.table .byline { display: block; line-height: 1.35; }
.attendance-list .who .byline { font-size: 0.75rem; }

/* Attendance per session */
#attendance-sessions { display: grid; gap: 12px; }
.att-student-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.att-student-head > span:first-child { font-weight: 600; font-size: 1.05rem; }
.attendance-list li.is-today { background: var(--sage-soft); }
.attendance-list li.is-future { opacity: .6; }
.attendance-list .who .tag { margin-inline-start: 4px; font-size: 0.72rem; padding: 1px 8px; }
.seg button:disabled { cursor: not-allowed; opacity: .6; }

/* Student page: his sessions this week */
.profile-sessions__head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
}
.profile-sessions__head h3 { margin: 0; }
.profile-sessions .empty { padding: 22px; }

/* Attendance: all students × the week's sessions */
.att-grid-wrap { overflow-x: auto; }
.att-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.att-grid th, .att-grid td { border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); padding: 8px 10px; text-align: start; vertical-align: middle; }
.att-grid tr > :first-child { border-inline-start: none; }
.att-grid tbody tr:last-child > * { border-bottom: none; }
.att-grid thead th { background: var(--surface-2); vertical-align: top; min-width: 150px; }
.att-grid thead th > span { display: block; }
.att-grid thead th.today { background: var(--sage-soft); }
.att-grid thead th.is-future { opacity: .6; }
.att-grid thead .day-name { font-weight: 600; white-space: nowrap; }
.att-grid__time { font-variant-numeric: tabular-nums; direction: ltr; text-align: end; font-weight: 500; }
[dir="ltr"] .att-grid__time { text-align: start; }
.att-grid__note { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.att-grid__count { color: var(--muted); font-size: 0.76rem; font-weight: 400; margin-top: 2px; }
.att-grid__all { margin-top: 6px; padding: 4px 10px; font-size: 0.76rem; }
.att-grid__corner, .att-grid__name {
  position: sticky; inset-inline-start: 0; z-index: 1;
  background: var(--surface); min-width: 140px; font-weight: 500;
}
.att-grid thead .att-grid__corner { background: var(--surface-2); z-index: 2; color: var(--muted); }
.att-grid td.today { background: var(--today-bg); }
.seg--mini { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; }
.seg--mini button { padding: 4px 9px; font-size: 0.78rem; }
@media (max-width: 860px) {
  .att-grid .seg--mini { justify-content: flex-start; }
  .att-grid .seg--mini button { flex: none; }
}
#attendance-student:disabled { opacity: .6; }

/* ---------- Program ---------- */
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--sage); width: 16px; height: 16px; }
.program-wrap { overflow-x: auto; }
.program { width: 100%; border-collapse: collapse; min-width: 640px; }
.program th {
  font-weight: 500; font-size: 0.8rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  text-align: start;
}
.program td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.program tr:last-child td { border-bottom: none; }
.program th.today { color: var(--sage-dark); background: var(--sage-soft); }
.program td.today { background: var(--today-bg); }
.program__time { width: 1%; white-space: nowrap; padding-inline-start: 16px !important; }
.program__time input {
  width: 112px; padding: 6px 6px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; font-size: 0.85rem; color: var(--muted);
}
.program__num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-inline-end: 4px;
  border-radius: 50%; background: var(--sage-soft); color: var(--sage-dark); font-size: 0.75rem; font-weight: 600;
}
.program__cell {
  width: 100%; min-width: 90px; padding: 9px 10px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); font-size: 0.9rem;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.program__cell:hover, .program__time input:hover { border-color: var(--border); }
.program__cell:focus, .program__time input:focus {
  outline: none; border-color: var(--sage); background: var(--surface); box-shadow: 0 0 0 3px var(--sage-soft);
}
.program__cell:not(:placeholder-shown) { background: var(--surface); border-color: var(--border); }
.program-actions { display: flex; gap: 10px; margin-top: 14px; }
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav .btn { padding: 8px 14px; font-size: 0.88rem; }
.week-label { font-weight: 600; padding: 0 6px; min-width: 190px; text-align: center; }
.week-label.is-current { color: var(--sage-dark); }
.program th .day-name { display: block; }
.program th .day-date { display: block; font-size: 0.75rem; font-weight: 400; opacity: .8; text-transform: none; letter-spacing: 0; }
.program-actions--center { justify-content: center; margin-top: 14px; }

.today-program { display: grid; gap: 12px; }
.today-program__row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.today-program__row .tag { flex-shrink: 0; }
.today-program__lessons { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.9rem; }
.lesson { padding: 3px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.lesson .muted { font-size: 0.78rem; margin-inline-end: 4px; }

/* ---------- Stats extras ---------- */
.stat__sub { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; }
.stat:nth-child(5) .stat__value { color: var(--clay); }
.stat:nth-child(4) .stat__value { color: var(--sand); }
.stat:nth-child(3) .stat__value { color: var(--sky); }
.stat:nth-child(2) .stat__value { color: var(--sage-dark); }
.stat:nth-child(1) .stat__value { color: var(--text); }
.card__head { padding: 20px 22px 0; }
.card__head h3 { margin-bottom: 12px; }

/* ---------- Needs attention ---------- */
.attention-list, .activity-list { list-style: none; display: grid; gap: 4px; }
.attention-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%;
  padding: 10px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; text-align: start; cursor: pointer; font-size: 0.92rem;
  transition: background .2s;
}
.attention-item:hover { background: var(--surface-2); }
.attention-item .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--sky); }
.attention-item.warn .dot { background: var(--sand); }
.attention-item.alert .dot { background: var(--clay); }
.attention-item .go { margin-inline-start: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; padding-top: 2px; }
.all-good { color: var(--sage-dark); font-size: 0.92rem; padding: 10px 12px; }

/* ---------- Recent activity ---------- */
.activity-item { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.activity-item:last-child { border-bottom: none; }
.avatar--sm { width: 28px; height: 28px; font-size: 0.75rem; }
.activity-item .when { display: block; font-size: 0.78rem; color: var(--muted); }

/* ---------- Attendance bar ---------- */
.att-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.att-bar span { display: block; height: 100%; }
.att-bar .present { background: var(--sage); }
.att-bar .late { background: var(--sand); }
.att-bar .absent { background: var(--clay); }
.att-bar .unmarked { background: var(--border); }
.att-mini { display: grid; gap: 4px; min-width: 140px; }
.att-mini .muted { font-size: 0.78rem; }
.glance-table tbody tr { cursor: pointer; }

/* ---------- Classes page ---------- */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.class-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: grid; gap: 12px; align-content: start;
  border: 1px solid transparent; cursor: pointer; text-align: start;
  transition: transform .15s var(--ease), border-color .2s, box-shadow .2s;
}
.class-card:hover { transform: translateY(-2px); border-color: var(--sage-soft); box-shadow: 0 2px 4px rgba(0,0,0,.2), 0 14px 30px rgba(0,0,0,.35); }
.class-card__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.class-card__name { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.class-card__meta { font-size: 0.85rem; color: var(--muted); }
.class-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; }
.mini-stat b { font-size: 1.1rem; font-weight: 600; }
.mini-stat span { font-size: 0.72rem; color: var(--muted); line-height: 1.25; }
.class-card__lessons { font-size: 0.85rem; color: var(--muted); }
.class-card__lessons b { color: var(--text); font-weight: 500; }

.class-detail { display: grid; gap: 20px; }
.back-btn { justify-self: start; margin: 0; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 500; }
.status-pill.present { background: var(--sage-soft); color: var(--sage-dark); }
.status-pill.late { background: var(--sand-soft); color: var(--sand-text); }
.status-pill.absent { background: var(--clay-soft); color: var(--clay); }
.status-pill.unmarked { background: var(--surface-2); color: var(--muted); }
.overdue-count { color: var(--clay); font-weight: 500; }

#classes-index { display: grid; gap: 20px; }
#classes-index .view__header { margin-bottom: -4px; }

/* ---------- Clickable student names ---------- */
.link-name {
  background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit;
  cursor: pointer; text-align: start;
}
.link-name:hover { color: var(--sage-dark); text-decoration: underline; text-underline-offset: 3px; }
.tag.link-name { background: var(--sage-soft); padding: 3px 10px; font-size: 0.78rem; font-weight: 500; color: var(--sage-dark); }
.tag.link-name:hover { text-decoration: none; background: var(--accent-soft-2); }

/* ---------- Student profile ---------- */
.profile { display: grid; gap: 20px; }
.profile__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.profile__id { display: flex; gap: 16px; align-items: center; }
.avatar--lg { width: 56px; height: 56px; font-size: 1.4rem; }
.profile__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.today-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.history-list { list-style: none; display: grid; max-height: 420px; overflow-y: auto; }
.history-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.history-list li:last-child { border-bottom: none; }
.history-list .byline { display: block; }
.status-pill.done { background: var(--sage-soft); color: var(--sage-dark); }
.status-pill.missing { background: var(--clay-soft); color: var(--clay); }
.status-pill.upcoming { background: var(--sky-soft); color: var(--sky-text); }
.status-pill.pending { background: var(--sand-soft); color: var(--sand-text); }

/* ---------- Chip pickers ---------- */
.picker { display: grid; gap: 8px; margin-top: 16px; }
.form .picker { margin-top: 0; grid-column: 1 / -1; }
.picker__label { font-size: 0.85rem; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.85rem; color: var(--text);
  transition: background .2s, border-color .2s, color .2s;
}
.chip:hover { border-color: var(--sage); }
.chip.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.chip.on::before { content: "✓ "; }
.chip-row .muted { font-size: 0.85rem; }
.detail-actions { display: flex; gap: 4px; }

/* ---------- Special teacher permissions ---------- */
.perm-box { display: grid; gap: 10px; grid-column: 1 / -1; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.perm-grid { display: grid; grid-template-columns: max-content minmax(160px, 260px); gap: 8px 16px; align-items: center; font-size: 0.9rem; }
.perm-grid select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.perm-summary { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.perm-summary .tag { font-size: 0.72rem; }
.tag--special { background: var(--sand-soft); color: var(--sand-text); }
.tag.view { background: var(--sky-soft); color: var(--sky-text); }

/* Hide add / edit / delete controls for areas a special teacher may only view */
body.no-edit-students   [data-edit="students"],
body.no-edit-attendance [data-edit="attendance"],
body.no-edit-homework   [data-edit="homework"],
body.no-edit-behavior   [data-edit="behavior"],
body.no-edit-schedule   [data-edit="schedule"] { display: none !important; }
body.no-edit-attendance [data-edit-soft="attendance"],
body.no-edit-homework   [data-edit-soft="homework"],
body.no-edit-schedule   [data-edit-soft="schedule"] { pointer-events: none; opacity: .75; }
body.no-edit-schedule .program input { pointer-events: none; }
body.no-view-students   [data-view-area="students"],
body.no-view-attendance [data-view-area="attendance"],
body.no-view-homework   [data-view-area="homework"],
body.no-view-behavior   [data-view-area="behavior"],
body.no-view-schedule   [data-view-area="schedule"] { display: none !important; }

.stat.v-text  .stat__value { color: var(--text); }
.stat.v-sky   .stat__value { color: var(--sky); }
.stat.v-sand  .stat__value { color: var(--sand); }
.stat.v-clay  .stat__value { color: var(--clay); }

@media (max-width: 860px) {
  .sidebar .brand { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat__value { font-size: 1.6rem; }
  .nav__item { padding: 9px 8px; }
  .class-card__stats { grid-template-columns: repeat(3, 1fr); }
  .glance-table th:nth-child(5), .glance-table td:nth-child(5),
  .glance-table th:nth-child(4), .glance-table td:nth-child(4) { display: none; }
}

/* ---------- Modal & toast ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 8, 14, .62);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px; z-index: 50;
  animation: fade .2s;
}
.modal__box {
  background: var(--surface);
  border-radius: 18px; padding: 26px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal__box h3 { margin-bottom: 6px; }
#confirm-modal { z-index: 60; } /* above the session dialog */
#confirm-text { white-space: pre-line; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--clay); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-inline-end: none; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .sidebar .brand__name { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav__item span { display: none; }
  .nav__item { padding: 10px; }
  .sidebar__footer { margin: 0 0 0 auto; display: flex; align-items: center; }
  .user-chip { display: none; }
  .sidebar__footer .btn { width: auto; padding: 7px 12px; font-size: 0.85rem; }

  .main { padding: 24px 16px 60px; }
  .field--wide { grid-column: auto; }
  .attendance-list li { flex-direction: column; align-items: stretch; }
  .seg { justify-content: space-between; }
  .seg button { flex: 1; }
  .table th, .table td { padding: 12px 14px; }
}

/* ---------- Languages ---------- */
.lang-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.lang-btn:hover { border-color: var(--sage); background: var(--surface); }
.login-card .lang-btn { margin-top: 14px; }
.footer-actions { display: flex; gap: 8px; align-items: center; }
.footer-actions .btn { flex: 1; }

/* Arabic: a font made for Arabic, slightly larger and with more line height */
html[lang="ar"] body { font-family: "IBM Plex Sans Arabic", "DM Sans", system-ui, Tahoma, sans-serif; font-size: 15.5px; line-height: 1.65; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] .stat__value, html[lang="ar"] .class-card__name { letter-spacing: 0; }
html[lang="ar"] .table th, html[lang="ar"] .program th, html[lang="ar"] .role-badge, html[lang="ar"] .side-classes__title { letter-spacing: 0; text-transform: none; }
/* Class names, emails, times and numbers stay left-to-right inside Arabic text */
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="time"], html[dir="rtl"] input[type="date"] { direction: ltr; text-align: right; }
html[dir="rtl"] .user-chip__email, html[dir="rtl"] .tiny.muted { unicode-bidi: plaintext; }
html[dir="rtl"] details.hw-students summary::before { content: "◂ "; }
html[dir="rtl"] details.hw-students[open] summary::before { content: "▾ "; }

.logout-icon { display: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html[dir="rtl"] .logout-icon { transform: scaleX(-1); }
@media (max-width: 860px) {
  .sidebar .lang-btn { font-size: 0; padding: 6px 10px; }
  .sidebar .lang-btn::after { content: attr(data-short); font-size: 0.85rem; }
  #logout-btn span { display: none; }
  #logout-btn .logout-icon { display: block; }
  .nav__item { padding: 9px 6px; }
  .nav { gap: 0; }
  .sidebar { gap: 6px; padding: 10px; }
  .footer-actions { gap: 4px; }
  .sidebar__footer .btn { padding: 7px 9px; }
}

/* ---------- Schedule: week board of sessions ---------- */
#program-body { min-width: 0; display: grid; gap: 12px; }
.program-toolbar { justify-content: space-between; }
.week-board {
  display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px;
  overflow-x: auto; padding: 2px 2px 6px;
}
.day-col {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; min-height: 220px;
  border: 1px solid var(--border);
}
.day-col.today { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft), var(--shadow); }
.day-col__head {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 12px 12px 10px; border-bottom: 1px solid var(--border);
}
.day-col__head > div { display: grid; gap: 1px; min-width: 0; }
.day-col__head .day-name { font-weight: 600; font-size: 0.92rem; }
.day-col__head .day-date { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.day-col.today .day-col__head { background: var(--sage-soft); border-radius: var(--radius) var(--radius) 0 0; }
.day-col.today .day-name { color: var(--sage-dark); }
.day-col__add {
  flex-shrink: 0; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  border: 1px dashed var(--border); border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer;
  opacity: .7; transition: opacity .2s, background .2s, color .2s, border-color .2s;
}
.day-col:hover .day-col__add, .day-col__add:focus-visible { opacity: 1; }
.day-col__add:hover { background: var(--sage-soft); color: var(--sage-dark); border-color: var(--sage); }
.day-col__body { display: grid; gap: 8px; padding: 10px; flex: 1; align-content: start; }
.no-class__text { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 18px 0; }
.day-col.no-class { background: var(--surface-2); box-shadow: none; }
.day-col.no-class.today { border-color: var(--sage); }

/* One session */
.slot {
  position: relative; display: grid; gap: 5px;
  padding: 10px 11px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--sage);
  font-size: 0.85rem; text-align: start;
}
.slot--once { border-inline-start-color: var(--sky); }
.slot.is-editable { cursor: pointer; transition: box-shadow .2s, transform .15s var(--ease); }
.slot.is-editable:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transform: translateY(-1px); }
.slot.is-editable:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--sage-soft); }
.slot.is-pending { border-style: dashed; border-inline-start-style: solid; border-inline-start-color: var(--sand); background: var(--sand-tint); }
.slot.is-rejected { border-inline-start-color: var(--clay); background: var(--clay-tint); opacity: .85; }
.slot.is-cancelled { opacity: .6; }
.slot.is-cancelled .slot__time span, .slot.is-cancelled .slot__title { text-decoration: line-through; }
.slot__time { display: flex; align-items: center; gap: 5px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; justify-content: flex-end; }
[dir="ltr"] .slot__time { justify-content: flex-start; }
.slot__time svg, .slot__place svg { color: var(--muted); flex-shrink: 0; }
.slot__title { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.slot__place { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.slot__segments {
  margin: 2px 0 0; padding-inline-start: 18px;
  color: var(--muted); font-size: 0.78rem; line-height: 1.45;
  border-top: 1px dashed var(--border); padding-top: 5px;
}
.slot__badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 1px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 500; white-space: nowrap;
}
.badge--main { background: var(--sage-soft); color: var(--sage-dark); }
.badge--once { background: var(--sky-soft); color: var(--sky-text); }
.badge--pending { background: var(--sand-soft); color: var(--sand-text); }
.badge--rejected { background: var(--clay-soft); color: var(--clay); }
.badge--cancelled { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend__dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--sage); }
.legend__dot--once { background: var(--sky); }

/* General schedule (read-only table of every program) */
#view-timetable .view__header { align-items: center; }
#timetable-body { display: grid; gap: 12px; }
.tt-wrap { overflow-x: auto; }
.tt { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 860px; font-size: 0.85rem; }
.tt th, .tt td { border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); vertical-align: top; text-align: start; }
.tt tr > :first-child { border-inline-start: none; }
.tt tbody tr:last-child > * { border-bottom: none; }
.tt thead th {
  padding: 10px 10px 8px; background: var(--surface-2);
  font-weight: 600; font-size: 0.85rem; white-space: nowrap;
}
.tt thead th .day-name { display: block; }
.tt thead th .day-date { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.tt thead th.today { background: var(--sage-soft); color: var(--sage-dark); }
.tt td.today { background: var(--today-bg); }
.tt__corner { color: var(--muted); font-weight: 500 !important; }
.tt__class, .tt__corner {
  position: sticky; inset-inline-start: 0; z-index: 1;
  background: var(--surface); min-width: 110px; padding: 12px 14px;
}
.tt thead .tt__corner { background: var(--surface-2); z-index: 2; }
.tt__class { font-weight: 600; font-size: 0.95rem; }
.tt__class span:first-child { display: block; }
.tt__class .badge { margin-top: 4px; }
.tt tr.is-mine .tt__class { background: var(--today-bg); }
.tt td { padding: 6px; min-width: 104px; }
.tt-item {
  display: grid; gap: 2px; padding: 6px 8px; margin-bottom: 5px;
  border-radius: 8px; background: var(--surface-2);
  border-inline-start: 3px solid var(--sage);
}
.tt-item:last-child { margin-bottom: 0; }
.tt-item--once { border-inline-start-color: var(--sky); }
.tt-item__time { font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
[dir="ltr"] .tt-item__time { text-align: start; }
.tt-item__title { line-height: 1.3; overflow-wrap: anywhere; }
.tt-item__place { display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 0.76rem; overflow-wrap: anywhere; }
.tt-item__place svg { flex-shrink: 0; width: 12px; height: 12px; }
.tt-empty { display: block; text-align: center; color: var(--border); padding: 8px 0; }

/* Waiting for approval (managers) */
.pending-card { border: 1px solid var(--sand-soft); }
.pending-card h3 { display: flex; align-items: center; gap: 8px; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--sand); color: #fff; font-size: 0.75rem; font-weight: 600;
}
.pending-list { list-style: none; display: grid; }
.pending-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.pending-list li:last-child { border-bottom: none; padding-bottom: 0; }
.pending-list__info { display: grid; gap: 3px; min-width: 0; font-size: 0.9rem; }
.pending-list__info .muted { font-size: 0.82rem; }
.pending-list__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pending-list__actions .btn { padding: 7px 14px; font-size: 0.85rem; }

/* Add / edit session dialog */
.modal__box--wide { max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; display: grid; gap: 16px; }
.modal__head { display: flex; align-items: center; gap: 10px; }
.modal__head h3 { margin: 0; }
.modal__close { margin-inline-start: auto; font-size: 1rem; }
.notice--soft { padding: 10px 14px; font-size: 0.85rem; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice button {
  display: grid; gap: 2px; text-align: start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.choice button b { font-weight: 600; font-size: 0.92rem; }
.choice button small { color: var(--muted); font-size: 0.78rem; }
.choice button:hover:not(:disabled) { border-color: var(--sage); }
.choice button.on { border-color: var(--sage); background: var(--sage-soft); box-shadow: 0 0 0 1px var(--sage) inset; }
.choice button.on b { color: var(--sage-dark); }
.choice button:disabled:not(.on) { opacity: .45; cursor: not-allowed; }
.choice button:disabled.on { cursor: default; }
#session-kind-hint { font-size: 0.8rem; }
.session-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.session-grid .field--full { grid-column: 1 / -1; }
.session-grid select:disabled { opacity: .7; }
.segment-list { display: grid; gap: 6px; }
.segment-list:empty { display: none; }
.segment-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; }
.segment-row__num {
  width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; background: var(--sage-soft); color: var(--sage-dark);
  font-size: 0.75rem; font-weight: 600;
}
.segment-add { justify-self: start; padding: 7px 12px; font-size: 0.85rem; }
.modal__actions--split { justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 0; }
.modal__left, .modal__right, #session-review:not(.hidden) { display: flex; gap: 6px; flex-wrap: wrap; }
.modal__right { margin-inline-start: auto; }

@media (max-width: 860px) {
  .week-board { grid-template-columns: 1fr; overflow: visible; }
  .day-col { min-height: 0; }
  .day-col__body { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .day-col.no-class .day-col__body { padding: 6px 12px; }
  .no-class__text { text-align: start; padding: 4px 0; }
  .day-col__add { opacity: 1; }
}
@media (max-width: 520px) {
  .session-grid, .choice { grid-template-columns: 1fr; }
  .view__header:has(#program-add) { flex-wrap: wrap; }
}

/* =========================================================
   THEME LAYER — البرامج (dark, grainy blue · matte gray · electric coral)
   Placed last so it refines the rules above.
   ========================================================= */

/* ---------- Page background: deep blue with soft glows and film grain ---------- */
html { background: var(--bg); }
body {
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(64, 98, 168, 0.28), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255, 107, 87, 0.07), transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 55%);
  background-attachment: fixed;
  color: var(--text);
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .10; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.app, .login-view, .loading-screen { position: relative; z-index: 1; }
.loading-screen { background: transparent; }
::selection { background: var(--accent-soft-2); color: var(--text); }
h1, h2 { color: #f1f3f7; }
h3 { color: var(--text); }

/* Thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Keyboard focus: one clear coral ring everywhere */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

.spinner { border-color: var(--surface-3); border-top-color: var(--accent); }

/* ---------- Brand lockup ---------- */
.brand { gap: 12px; }
.brand__mark {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #ff8a6a 0%, var(--accent) 55%, #e8473a 100%);
  color: var(--accent-ink);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-weight: 700; font-size: 1.35rem; line-height: 1;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, var(--accent-glow);
  padding-bottom: 4px; /* optical centre for ب */
}
.brand__text { display: grid; line-height: 1.1; min-width: 0; }
.brand__name {
  font-family: "IBM Plex Sans Arabic", "DM Sans", sans-serif;
  font-weight: 700; font-size: 1.22rem; color: #f3f5f9; letter-spacing: 0;
}
.brand__sub {
  font-family: "DM Sans", sans-serif;
  font-size: 0.62rem; font-weight: 600; letter-spacing: .32em;
  color: var(--accent); margin-top: 3px; direction: ltr; text-align: start;
}
html[dir="rtl"] .brand__sub { text-align: right; }
.brand--center { flex-direction: column; gap: 14px; margin-bottom: 26px; }
.brand--center .brand__mark { width: 58px; height: 58px; border-radius: 16px; font-size: 2rem; }
.brand--center .brand__text { text-align: center; justify-items: center; }
.brand--center .brand__name { font-size: 1.7rem; }
.brand--center .brand__sub { font-size: 0.7rem; text-align: center; }

/* ---------- Login ---------- */
.login-view {
  background:
    radial-gradient(700px 500px at 50% 0%, rgba(80, 118, 196, 0.25), transparent 70%),
    radial-gradient(500px 400px at 50% 100%, rgba(255, 107, 87, 0.10), transparent 70%);
}
.login-card {
  background: linear-gradient(180deg, rgba(34, 40, 51, 0.92), rgba(27, 32, 41, 0.92));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 34px 30px;
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(10px);
}
.login-card h1 { font-size: 1.35rem; }
.login-card .btn--primary { padding: 12px 18px; font-size: 1rem; }

/* ---------- Inputs ---------- */
.field { color: var(--text-2); }
.field input, .field select, .input, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.field input::placeholder, .input::placeholder { color: #6b7383; }
.field input:hover, .field select:hover, .input:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus, .input:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select option { background: var(--surface-2); color: var(--text); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(.8); cursor: pointer; }
input:disabled, select:disabled { opacity: .55; }
.check input { accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 600; letter-spacing: .005em; }
.btn--primary {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 4px 14px rgba(255, 107, 87, 0.22);
}
.btn--primary:hover { background: linear-gradient(180deg, #ff9585, var(--accent-strong)); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, var(--accent-glow); }
.btn--soft { background: var(--accent-soft); color: var(--accent-strong); border-color: rgba(255, 107, 87, 0.18); }
.btn--soft:hover { background: var(--accent-soft-2); }
.btn--ghost { background: rgba(255, 255, 255, 0.02); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-3); border-color: #4a5363; }
.btn--danger { background: var(--clay); color: #fff; }
.btn--danger:hover { background: var(--clay-strong); }
.btn.icon-btn--danger { color: var(--clay-strong); }
.icon-btn { color: var(--muted); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--danger:hover { background: var(--clay-soft); color: var(--clay-strong); }
.link-btn { color: var(--accent-strong); font-weight: 500; }
.back-btn { color: var(--text-2); }
.back-btn:hover { color: var(--accent-strong); text-decoration: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: rgba(22, 27, 36, 0.78);
  border-inline-end: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  padding: 24px 16px;
}
.nav { gap: 2px; }
.nav__item { position: relative; color: var(--muted); padding: 10px 12px; font-weight: 500; }
.nav__item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav__item.active { background: var(--accent-soft); color: #ffd9d3; font-weight: 600; }
.nav__item.active svg { color: var(--accent); }
.nav__item.active::before {
  content: ""; position: absolute; inset-inline-start: -16px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
html[dir="rtl"] .nav__item.active::before { border-radius: 3px 0 0 3px; }
.sidebar__footer {
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px; padding: 12px;
}
.avatar { background: linear-gradient(145deg, #2d3a55, #233049); color: #cfe0ff; box-shadow: 0 0 0 1px rgba(255,255,255,.06) inset; }
.user-chip__email { color: var(--text-2); }
.role-badge { color: var(--sage-dark); }
.role-badge.manager { color: var(--accent-strong); }
.lang-btn { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-2); }
.lang-btn:hover { border-color: var(--accent); background: var(--surface-3); color: var(--text); }

/* ---------- Cards & surfaces ---------- */
.card, .stat, .hw-card, .behavior-item, .class-card, .day-col, .modal__box {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0) 40%), var(--surface);
  border: 1px solid var(--border);
}
.behavior-item { border-inline-start-width: 4px; }
.class-card:hover, .hw-card.is-clickable:hover { border-color: rgba(255, 107, 87, 0.45); box-shadow: var(--shadow-lift); }
.card--flush { overflow: hidden; }
.view__header h2 { font-size: 1.6rem; }
.view__header p.muted { color: var(--text-2); opacity: .8; }

/* Stats: a thin colour line on top */
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--border-strong); opacity: .9; }
.stat.v-sky::before, .stat:nth-child(3)::before { background: var(--sky); }
.stat.v-sand::before, .stat:nth-child(4)::before { background: var(--sand); }
.stat.v-clay::before, .stat:nth-child(5)::before { background: var(--clay); }
.stat:nth-child(1)::before, .stat.v-text::before { background: var(--accent); }
.stat:nth-child(2)::before { background: var(--sage); }
.stat__value { color: #f3f5f9; }

/* Tables */
.table th, .att-grid thead th, .tt thead th { background: var(--surface-2); color: var(--muted); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.att-grid__corner, .att-grid__name, .tt__class, .tt__corner { background: var(--surface); }
.att-grid thead .att-grid__corner, .tt thead .tt__corner { background: var(--surface-2); }
.tt-empty { color: var(--border-strong); }

/* Tags & pills */
.tag { background: var(--surface-3); color: var(--text-2); }
.tag.link-name { background: var(--accent-soft); color: var(--accent-strong); }
.tag.link-name:hover { background: var(--accent-soft-2); }
.link-name:hover { color: var(--accent-strong); }
.tag--positive, .status-pill.present, .status-pill.done, .pill--present { background: var(--sage-soft); color: var(--sage-dark); }
.tag--neutral { background: var(--sky-soft); color: var(--sky-text); }
.tag--concern, .status-pill.absent, .status-pill.missing, .pill--absent { background: var(--clay-soft); color: var(--clay-strong); }
.badge--main { background: var(--sage-soft); color: var(--sage-dark); }
.badge--once { background: var(--sky-soft); color: var(--sky-text); }
.count-badge { background: var(--accent); color: var(--accent-ink); }

/* Present / absent toggles */
.seg { background: var(--surface-2); border: 1px solid var(--border); }
.seg button { color: var(--muted); font-weight: 500; }
.seg button:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.seg button.on-present { background: var(--sage-soft); color: var(--sage-dark); box-shadow: 0 0 0 1px rgba(79, 195, 161, 0.35) inset; }
.seg button.on-late    { background: var(--sand-soft); color: var(--sand-text); box-shadow: 0 0 0 1px rgba(232, 178, 100, 0.35) inset; }
.seg button.on-absent  { background: var(--clay-soft); color: var(--clay-strong); box-shadow: 0 0 0 1px rgba(240, 86, 95, 0.35) inset; }

/* Progress, chips, choices */
.progress { background: var(--surface-3); }
.progress span { background: linear-gradient(90deg, var(--accent), var(--accent-strong)); box-shadow: 0 0 10px rgba(255, 107, 87, 0.45); }
.chip { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-2); }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.choice button { background: var(--surface-2); border-color: var(--border); }
.choice button:hover:not(:disabled) { border-color: var(--accent); }
.choice button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice button.on b { color: var(--accent-strong); }
.segment-row__num { background: var(--accent-soft); color: var(--accent-strong); }
.perm-box { background: var(--surface-2); border: 1px solid var(--border); }
.perm-grid select { background: var(--surface-3); border-color: var(--border-strong); }
.notice { background: var(--sand-soft); color: var(--sand-text); border: 1px solid rgba(232, 178, 100, 0.2); }

/* "Today" and the current week are coral */
.week-label.is-current { color: var(--accent-strong); }
.day-col.today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.day-col.today .day-col__head, .att-grid thead th.today, .tt thead th.today { background: var(--accent-soft); }
.day-col.today .day-name, .tt thead th.today { color: var(--accent-strong); }
.day-col.no-class { background: rgba(27, 32, 41, 0.55); }
.day-col.no-class.today { border-color: var(--accent); }
.day-col__add:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.attendance-list li.is-today { background: var(--today-bg); box-shadow: inset 3px 0 0 var(--accent); }
html[dir="rtl"] .attendance-list li.is-today { box-shadow: inset -3px 0 0 var(--accent); }
.slot { background: var(--surface-2); }
.slot.is-editable:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); border-color: var(--border-strong); }
.slot.is-editable:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.tt-item { background: var(--surface-2); }
.lesson { background: var(--surface-2); border-color: var(--border); }
.mini-stat { background: var(--surface-2); }
.hw-link { background: var(--surface-2); border-color: var(--border); }
.hw-link:hover { background: var(--surface-3); border-color: var(--border-strong); }
.hw-card__open { color: var(--accent-strong); }
.all-good { color: var(--sage-dark); }
.attention-item:hover { background: rgba(255, 255, 255, 0.035); }
.byline b { color: var(--text-2); }
.replies { border-inline-start-color: var(--border-strong); }

/* ---------- Dialogs & messages ---------- */
.modal { background: rgba(5, 8, 14, 0.62); backdrop-filter: blur(6px); }
.modal__box { box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); }
.toast { background: #2a313d; color: var(--text); border: 1px solid var(--border-strong); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }
.toast.error { background: #3a1e24; border-color: rgba(240, 86, 95, 0.5); color: #ffd6d9; }

@media (max-width: 860px) {
  .sidebar { padding: 10px 12px; background: rgba(18, 23, 32, 0.92); }
  .sidebar__footer { background: none; border: none; padding: 0; }
  .nav__item.active::before { display: none; }
  .brand__text { display: none; }
  .sidebar .brand { display: flex; padding: 0; }
  .sidebar .brand__mark { width: 32px; height: 32px; font-size: 1.1rem; border-radius: 9px; }
}

/* Sidebar footer: language + sign out side by side, always inside the box */
.sidebar__footer { padding: 10px; gap: 10px; }
.footer-actions { display: grid; grid-template-columns: auto 1fr; gap: 6px; }
.footer-actions .btn { min-width: 0; padding: 8px 10px; font-size: 0.85rem; }
.footer-actions .lang-btn { padding: 7px 12px; font-size: 0.8rem; }
.user-chip { padding: 0 2px; }
@media (max-width: 860px) {
  .footer-actions { display: flex; }
}

/* "Today" tint: a whisper of coral, so it never looks like "absent" */
:root { --today-bg: rgba(255, 107, 87, 0.035); }
.att-grid thead th.today, .tt thead th.today { background: rgba(255, 107, 87, 0.09); }
.day-col.today .day-col__head { background: rgba(255, 107, 87, 0.10); }
