/* =====================================================================
   style.css -- shared by index.html and admin.html
   RTL-native (logical properties throughout), mobile-first, plus print.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --brand:        #14615a;
  --brand-ink:    #0d443f;
  --brand-soft:   #e6f2f0;
  --brand-line:   #b9dcd6;

  --ok:           #15803d;
  --ok-soft:      #e8f6ec;
  --warn:         #b45309;
  --warn-soft:    #fdf1e3;
  --bad:          #b42318;
  --bad-soft:     #fdeceb;

  --bg:           #f5f6f7;
  --surface:      #ffffff;
  --surface-2:    #fafbfb;
  --ink:          #14181c;
  --ink-2:        #4b5563;
  --ink-3:        #7b8794;
  --line:         #e3e6e9;
  --line-2:       #eef0f2;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --shadow:    0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .12);

  --pad: 16px;
  --bar-h: 64px;

  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:      #4db6a6;
    --brand-ink:  #7fd0c2;
    --brand-soft: #14302d;
    --brand-line: #24504a;

    --ok:      #5fbe7d;  --ok-soft:   #16301f;
    --warn:    #e0a250;  --warn-soft: #33240f;
    --bad:     #f0776c;  --bad-soft:  #3a1a17;

    --bg:        #101316;
    --surface:   #181c20;
    --surface-2: #1e2328;
    --ink:       #e8eaec;
    --ink-2:     #aab2bb;
    --ink-3:     #7f8994;
    --line:      #2a3037;
    --line-2:    #232930;

    --shadow:    0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, .55);
  }
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .96rem; }
p  { margin: 0 0 .6em; }
ul { margin: 0; padding: 0; list-style: none; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Latin runs (codes, times, digits) inside Arabic text.
   Without bidi isolation "CMP110-03" and "12 / 18" reorder on screen. */
.ltr, .num, .code, .time {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.code { font-weight: 600; letter-spacing: .01em; }

.muted   { color: var(--ink-2); }
.dim     { color: var(--ink-3); }
.small   { font-size: .85rem; }
.tiny    { font-size: .78rem; }
.hidden  { display: none !important; }
.nowrap  { white-space: nowrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.stack   { display: flex; flex-direction: column; gap: 10px; }
.row     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.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;
}

/* ---------- 3. Shell ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  padding: 10px var(--pad);
  display: flex; align-items: center; gap: 12px;
}
.appbar .brand-mark {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
@media (prefers-color-scheme: dark) { .appbar .brand-mark { color: #0d1f1d; } }

.appbar h1 { font-size: 1rem; }
.appbar .sub { font-size: .78rem; color: var(--ink-3); line-height: 1.2; }

.container {
  max-width: 1120px;
  margin-inline: auto;
  padding: var(--pad);
  padding-block-end: calc(var(--bar-h) + 28px);
}
.container.narrow { max-width: 460px; }

/* ---------- 4. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card + .card { margin-block-start: 14px; }
.card-head {
  padding: 13px 15px;
  border-block-end: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-body { padding: 15px; }

/* ---------- 5. Buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600; font-size: .92rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled)  { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled              { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .btn-primary { color: #08201d; } }
.btn-primary:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); }

.btn-danger { color: var(--bad); border-color: var(--line); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }

.btn-sm { min-height: 34px; padding: 4px 11px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* Busy state: the label is swapped for a spinner while a call is in flight. */
.btn[data-busy="1"] { pointer-events: none; opacity: .75; }
.spinner {
  width: 15px; height: 15px; flex: none;
  border: 2px solid currentColor;
  border-block-start-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---------- 6. Form fields ---------- */
.field { display: block; margin-block-end: 13px; }
.field > .label {
  display: block; margin-block-end: 5px;
  font-size: .86rem; font-weight: 600; color: var(--ink-2);
}
.input, .textarea, .select {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.input.ltr-input { direction: ltr; text-align: start; }
.input[type="number"] { max-width: 120px; }

.hint { font-size: .8rem; color: var(--ink-3); margin-block-start: 4px; }

/* ---------- 7. Notice / alerts ---------- */
.notice {
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-block-end: 14px;
  white-space: pre-wrap;      /* the teacher's line breaks are meaningful */
  overflow-wrap: anywhere;
}
.notice .notice-label {
  display: block;
  font-size: .74rem; font-weight: 700;
  letter-spacing: .04em;
  opacity: .75;
  margin-block-end: 3px;
}

.alert {
  border-radius: var(--r);
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: .92rem;
}
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-bad  { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad); }
.alert-ok   { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }

/* ---------- 8. Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .76rem; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-ok    { background: var(--ok-soft);    color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip-warn  { background: var(--warn-soft);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.chip-bad   { background: var(--bad-soft);   color: var(--bad);   border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.chip-mute  { background: var(--surface-2);  color: var(--ink-3); border-color: var(--line); }
.chip-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }

/* ---------- 9. Course + section list ---------- */
/* Courses collapse by default: 33 short rows instead of a 148-row wall. */
.course {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  margin-block-end: 9px;
  overflow: hidden;
}
.course > summary.course-head {
  padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .15s;
}
.course > summary.course-head::-webkit-details-marker { display: none; }
.course > summary.course-head:hover { background: var(--surface-2); }
.course[open] > summary.course-head {
  border-block-end: 1px solid var(--line-2);
  background: var(--surface-2);
}
.course-head .caret {
  flex: none;
  width: 0; height: 0;
  border-inline-start: 5px solid transparent;
  border-inline-end: 5px solid transparent;
  border-block-start: 6px solid var(--ink-3);
  transition: transform .18s;
}
.course[open] > .course-head .caret { transform: rotate(-90deg); }
.course-head .course-name { display: block; font-weight: 600; line-height: 1.4; }
.course-head .course-meta { display: block; font-size: .78rem; color: var(--ink-3); }
.ok-text  { color: var(--ok); }
.bad-text { color: var(--bad); }

.sections { padding: 7px; display: flex; flex-direction: column; gap: 6px; }

.section {
  position: relative;
  width: 100%;
  text-align: start;
  display: block;
  padding: 9px 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.section:hover:not(.is-blocked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.section.is-blocked { cursor: not-allowed; background: var(--surface-2); }
.section.is-blocked .section-top,
.section.is-blocked .section-meta,
.section.is-blocked .sec-teacher { opacity: .55; }
.section.is-mine { border-color: var(--ok); background: var(--ok-soft); }

.section-top { display: flex; align-items: center; gap: 6px; margin-block-end: 2px; }
.section-no {
  font-size: .9rem; font-weight: 700;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid var(--brand-line);
  flex: none;
}
.section-meta { display: block; font-size: .82rem; color: var(--ink-2); }
.sec-teacher { display: block; font-size: .76rem; color: var(--ink-3); margin-block-start: 1px; }
.seats { font-size: .78rem; color: var(--ink-2); flex: none; }

/* Fill level as a hairline along the bottom edge -- costs no vertical space. */
.bar {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  height: 3px;
  background: var(--line-2);
  overflow: hidden;
}
.bar > i {
  display: block; height: 100%;
  background: var(--ok);
  transition: width .3s ease;
}
.bar.is-warn > i { background: var(--warn); }
.bar.is-full > i { background: var(--bad); }

/* The reason a row is unavailable, written on the row itself. */
.blocked-why {
  display: block;
  margin-block-start: 5px;
  font-size: .78rem;
  color: var(--warn);
  font-weight: 600;
}
.section.is-mine .blocked-why { color: var(--ok); }

/* ---------- 9b. Incomplete نظري/عملي pair ----------
   A course offering both kinds must be taken as a set. Half a pair is a
   real failure state, so it is red and it follows the student around. */
.pair-warn { margin-block-end: 14px; }
.pair-warn .pair-title {
  font-weight: 700;
  font-size: 1rem;
  margin-block-end: 4px;
}
.pair-list { display: flex; flex-direction: column; gap: 7px; }
.pair-list li {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}
.pair-list li .btn { flex: none; }

.course.needs-pair {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-soft);
}
.course.needs-pair .course-head { background: var(--bad-soft); }

.mini.needs-pair {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.pair-flag {
  display: block;
  margin-block-start: 4px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--bad);
}

.sheet.is-incomplete { border-block-start: 2px solid var(--bad); }

/* Brief highlight when jumping to a course from the warning. */
.course.flash { animation: flash 1.5s ease; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 3px var(--bad-soft); }
  30%      { box-shadow: 0 0 0 7px color-mix(in srgb, var(--bad) 40%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .course.flash { animation: none; } }

/* ---------- 9d. Step 1: the course list ----------
   One clean scannable row per course, multi-select. This is the first
   question a student actually has: which subjects am I taking? */
.crow {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  border-block-end: 1px solid var(--line-2);
  cursor: pointer;
  transition: background .12s;
}
.crow:last-child { border-block-end: 0; }
.crow:hover { background: var(--surface-2); }
.crow input { position: absolute; opacity: 0; width: 0; height: 0; }

.crow-box {
  flex: none;
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  position: relative;
  transition: background .15s, border-color .15s;
}
.crow-box::after {
  content: '';
  position: absolute;
  inset-block-start: 2px; inset-inline-start: 6px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .15s;
}
.crow.is-on .crow-box { background: var(--brand); border-color: var(--brand); }
.crow.is-on .crow-box::after { transform: rotate(45deg) scale(1); }
@media (prefers-color-scheme: dark) { .crow-box::after { border-color: #08201d; } }
.crow input:focus-visible + .crow-box { outline: 2px solid var(--brand); outline-offset: 2px; }

.crow.is-on { background: var(--brand-soft); }
.crow.is-locked { cursor: default; }
.crow.is-locked .crow-box { opacity: .65; }

.crow-name { display: block; font-weight: 600; line-height: 1.4; }
.crow-meta { display: block; font-size: .78rem; color: var(--ink-3); }
.warn-text { color: var(--warn); }

/* Sticky action bar for step 1 */
.step-bar {
  position: fixed;
  inset-inline: 0; bottom: 0;
  z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 11px var(--pad);
  padding-bottom: calc(11px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-block-start: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, .10);
}
.step-bar .btn { flex: none; }

/* ---------- 9c. Picker filters ----------
   Sticky on every size: with 148 sections, search must never be more than
   a glance away. */
.filters {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  padding-block: 10px 8px;
  margin-block-end: 4px;
}
@media (min-width: 900px) { .filters { top: 66px; } }

.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute;
  inset-inline-start: 12px;
  inset-block-start: 50%;
  transform: translateY(-50%);
  font-size: .95rem;
  opacity: .5;
  pointer-events: none;
}
.search-input {
  min-height: 46px;
  padding-inline-start: 38px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.seg-mode {
  display: flex;
  width: 100%;
  margin-block-start: 8px;
}
.seg-mode button { flex: 1 1 0; min-height: 34px; font-size: .84rem; padding-inline: 6px; }

.day-filter { margin-block-start: 8px; }
.day-filter > summary {
  cursor: pointer;
  color: var(--ink-2);
  padding: 4px 2px;
  user-select: none;
}
.day-filter.is-on > summary { color: var(--brand); font-weight: 700; }
.daychips { display: flex; gap: 6px; flex-wrap: wrap; margin-block-start: 8px; }
.daychips button {
  padding: 6px 12px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
}
.daychips button[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .daychips button[aria-pressed="true"] { color: #08201d; } }

.list-bar {
  display: flex; align-items: center; gap: 8px;
  margin-block-end: 8px;
  min-height: 32px;
}

/* ---------- 10. Picker layout ---------- */
.picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
@media (min-width: 900px) {
  .picker { grid-template-columns: minmax(0, 1fr) 310px; }
  .side { position: sticky; top: 74px; }
  .container { padding-block-end: 28px; }
}

/* ---------- 11. Summary panel (desktop) / bottom sheet (mobile) ---------- */
.summary-line {
  display: flex; align-items: baseline; gap: 6px;
  font-size: .86rem; color: var(--ink-2);
}
.summary-hours { font-size: 1.35rem; font-weight: 700; color: var(--ink); }

.mini-list { display: flex; flex-direction: column; gap: 7px; }
.mini {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: .84rem;
}
.mini .mini-code { font-weight: 700; }
.mini .mini-when { color: var(--ink-3); font-size: .78rem; }

/* Mobile: fixed bar that expands upward into a sheet. */
.sheet {
  position: fixed;
  inset-inline: 0; bottom: 0;
  z-index: 40;
  background: var(--surface);
  border-block-start: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, .10);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-handle {
  width: 100%;
  min-height: var(--bar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--pad);
  background: none; border: 0; cursor: pointer;
  text-align: start;
}
.sheet-body {
  max-height: 52vh;
  overflow-y: auto;
  padding: 0 var(--pad) 14px;
  border-block-start: 1px solid var(--line-2);
}
.sheet[data-open="0"] .sheet-body { display: none; }
.sheet-caret { transition: transform .2s; color: var(--ink-3); }
.sheet[data-open="1"] .sheet-caret { transform: rotate(180deg); }

@media (min-width: 900px) { .sheet { display: none; } }
@media (max-width: 899px) { .side { display: none; } }

/* ---------- 12. Progress meter (hours) ---------- */
.meter {
  height: 7px; border-radius: 999px;
  background: var(--line-2);
  overflow: hidden;
  margin-block-start: 7px;
}
.meter > i {
  display: block; height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s ease;
}
.meter.is-full > i { background: var(--ok); }

/* ---------- 13. Tabs ---------- */
.tabs {
  display: flex; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-block-end: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-height: 38px;
  padding: 6px 14px;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600; font-size: .88rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--surface-2); }
.tab[aria-selected="true"] {
  background: var(--brand);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .tab[aria-selected="true"] { color: #08201d; } }
.tab .count {
  font-size: .76rem;
  opacity: .8;
  margin-inline-start: 5px;
}

/* ---------- 14. Weekly timeline ----------
   A real timeline, not a fixed grid: the college timetable puts
   10:00-11:04 next to 12:50-13:40, so meetings are positioned by their
   actual start and end. --tl-h is set inline from the data. */
.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.timeline { min-width: 620px; }

.tl-head, .tl-body {
  display: grid;
  grid-template-columns: 58px repeat(5, minmax(0, 1fr));
  gap: 4px;
}
.tl-head { margin-block-end: 4px; }
.tl-dayname {
  text-align: center;
  font-size: .82rem; font-weight: 600;
  color: var(--ink-2);
  padding-block-end: 2px;
}

.tl-body { height: var(--tl-h, 420px); }

.tl-axis { position: relative; }
.tl-axis .hour {
  position: absolute;
  inset-inline: 0;
  transform: translateY(-50%);
  text-align: center;
  font-size: .72rem;
  color: var(--ink-3);
}

.tl-day {
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0, transparent 62px,
      var(--line-2) 62px, var(--line-2) 63px);
  background-color: var(--surface-2);
}

.tl-item {
  position: absolute;
  inset-inline: 3px;
  overflow: hidden;
  padding: 4px 6px;
  border: 1px solid var(--brand-line);
  border-radius: 8px;
  background: var(--brand-soft);
  box-shadow: var(--shadow);
}
.tl-item .cell-code { font-size: .78rem; font-weight: 700; color: var(--brand-ink); display: block; }
.tl-item .cell-name { font-size: .72rem; color: var(--brand-ink); opacity: .9; display: block; line-height: 1.25; }
.tl-item .cell-room { font-size: .68rem; color: var(--brand-ink); opacity: .72; display: block; }

/* Meeting lines inside a section row / dialog */
.meet {
  display: block;
  font-size: .82rem;
  line-height: 1.6;
}
.meet + .meet { margin-block-start: 1px; }
.meet b { font-weight: 600; }

/* ---- A section that meets more than once a week ----
   It is booked as ONE unit: confirming puts every meeting into the week.
   The student has to see that before he commits, so the whole block is
   visually bracketed rather than left as two anonymous lines. */
.chip-pack {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.pack-note {
  display: block;
  font-size: .76rem;
  font-weight: 700;
  color: var(--warn);
  margin-block-end: 2px;
}
.meet-n {
  border-inline-start: 2px solid color-mix(in srgb, var(--warn) 45%, transparent);
  padding-inline-start: 8px;
  margin-inline-start: 2px;
}
.meet-idx {
  display: inline-grid; place-items: center;
  width: 15px; height: 15px;
  margin-inline-end: 5px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-size: .64rem; font-weight: 700;
  vertical-align: 1px;
}
@media (prefers-color-scheme: dark) { .meet-idx { color: #2a1c07; } }

.pack-banner {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  border-radius: var(--r);
  padding: 9px 11px;
  margin-block-end: 9px;
  font-size: .84rem;
  line-height: 1.65;
  text-align: start;
}

/* ---------- 15. Data tables (admin) ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.data th, table.data td {
  padding: 9px 11px;
  border-block-end: 1px solid var(--line-2);
  text-align: start;
  vertical-align: middle;
}
table.data thead th {
  font-size: .78rem;
  color: var(--ink-3);
  font-weight: 600;
  background: var(--surface-2);
  border-block-end: 1px solid var(--line);
  position: sticky; top: 0;
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-block-end: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
/* Rows flagged as a problem (e.g. a student whose نظري/عملي pair is
   incomplete). Was previously scoped to .grid only, so the students-tab
   highlight silently painted nothing. */
table.data tbody tr.bad td { background: var(--bad-soft); }

/* ---------- 16. Roster (admin tab 1) ---------- */
.roster-sec { break-inside: avoid; }
.roster-sec + .roster-sec { margin-block-start: 14px; }
.roster-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--surface-2);
  border-block-end: 1px solid var(--line-2);
}
/* The delete tick box. Sized up from the browser default so it is a real
   tap target on a phone, where the teacher actually uses this page. */
.roster-head input[type="checkbox"] {
  inline-size: 18px; block-size: 18px;
  flex: none; margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.roster-list { padding: 6px 0; }
.roster-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 14px;
  font-size: .88rem;
  border-block-end: 1px solid var(--line-2);
}
.roster-row:last-child { border-block-end: 0; }
.roster-row .idx {
  width: 26px; flex: none;
  color: var(--ink-3); font-size: .78rem;
}
.roster-row .sid { min-width: 84px; flex: none; font-weight: 600; }

/* ---------- 16b. Import: dropzone, mapping, review grid ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-icon { font-size: 1.9rem; display: block; margin-block-end: 6px; opacity: .7; }
.dropzone .dz-title { font-weight: 600; margin-block-end: 3px; }

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 10px;
}
.map-row { display: flex; align-items: center; gap: 8px; }
.map-row > .label {
  flex: none; width: 82px;
  font-size: .84rem; font-weight: 600; color: var(--ink-2);
}
.map-row select {
  flex: 1 1 auto; min-width: 0;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.map-row.is-missing select { border-color: var(--warn); background: var(--warn-soft); }

table.data.grid td { padding: 5px 7px; }
table.data.grid input[type="text"],
table.data.grid input[type="number"],
table.data.grid select {
  width: 100%;
  min-height: 32px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: .84rem;
}
table.data.grid input:focus, table.data.grid select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
table.data.grid tr.bad td { background: var(--bad-soft); }
table.data.grid tr.skip td { opacity: .45; }
table.data.grid .w-sec  { min-width: 122px; }
table.data.grid .w-name { min-width: 150px; }
table.data.grid .w-txt  { min-width: 105px; }

/* The spinner arrows eat ~13px and clip a two-digit value down to its last
   digit, so drop them and give the numeric cells a real floor. `width` here
   must out-rank the `width:100%` above -- min-width alone would not. */
table.data.grid input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
table.data.grid input[type="number"]::-webkit-outer-spin-button,
table.data.grid input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
table.data.grid input.w-num {
  width: 62px; min-width: 62px;
  text-align: center;
  direction: ltr;
}
table.data.grid input.w-time {
  width: 96px; min-width: 96px;
  direction: ltr;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.code-block {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  overflow-x: auto;
}

.daypick { display: flex; gap: 3px; }
.daypick button {
  width: 25px; height: 29px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: .8rem; font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.daypick button[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .daypick button[aria-pressed="true"] { color: #08201d; } }

.row-err { font-size: .76rem; color: var(--bad); line-height: 1.45; }

/* ---------- 17. Toggle switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px; flex: none;
  border-radius: 999px;
  background: var(--line);
  border: 1px solid var(--line);
  position: relative;
  transition: background .18s, border-color .18s;
}
.switch .track::after {
  content: '';
  position: absolute;
  inset-block-start: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(-18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* Segmented phase control */
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  background: var(--surface-2);
  gap: 3px;
  flex-wrap: wrap;
}
.segmented button {
  min-height: 36px;
  padding: 5px 14px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600; font-size: .86rem;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed="true"] { color: #08201d; } }
.segmented button:disabled { opacity: .6; cursor: default; }

/* ---------- 18. Dialog ---------- */
dialog.modal {
  border: 0;
  padding: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
}
dialog.modal::backdrop { background: rgba(9, 14, 20, .5); backdrop-filter: blur(2px); }
.modal-head { padding: 16px 18px 0; }
.modal-body { padding: 12px 18px 4px; }
.modal-foot {
  padding: 14px 18px 18px;
  display: flex; gap: 9px;
}
.modal-foot .btn { flex: 1 1 0; }

.modal-warn {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  border-radius: var(--r);
  padding: 11px 13px;
  font-size: .87rem;
  line-height: 1.6;
}

/* ---------- 19. Toast ---------- */
.toasts {
  position: fixed;
  inset-block-start: 12px;
  inset-inline: 12px;
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 460px; width: fit-content;
  padding: 11px 15px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--bg);
  font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease;
}
.toast.ok   { background: var(--ok);   color: #fff; }
.toast.bad  { background: var(--bad);  color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- 20. Empty & loading states ---------- */
.empty {
  text-align: center;
  padding: 34px 18px;
  color: var(--ink-3);
}
.empty .empty-icon { font-size: 1.7rem; opacity: .55; display: block; margin-block-end: 7px; }
.empty .empty-title { font-weight: 600; color: var(--ink-2); margin-block-end: 3px; }

.skeleton {
  border-radius: var(--r);
  background: linear-gradient(90deg, var(--line-2) 25%, var(--line) 37%, var(--line-2) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
  height: 74px;
  margin-block-end: 10px;
}
@keyframes sk { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Live-refresh pulse next to the seat counts */
.live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; color: var(--ink-3);
}
.live .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live .dot { animation: none; } }
.live.is-stale .dot { background: var(--warn); animation: none; }

/* ---------- 21. Print ---------- */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --ink: #000; --ink-2: #333; --ink-3: #555;
    --line: #bbb; --line-2: #ddd;
    --brand: #000; --brand-ink: #000; --brand-soft: #f2f2f2; --brand-line: #999;
    --shadow: none; --shadow-lg: none;
  }
  @page { margin: 12mm; }

  body { background: #fff; font-size: 11pt; }

  /* The teacher's guidance and the phase banner are aids for choosing, not
     part of the timetable -- they only clutter the printed page. */
  .appbar, .tabs, .sheet, .toasts, .no-print, .notice, .alert,
  .btn, .switch, .segmented, dialog.modal, .live, .skeleton { display: none !important; }

  .container { max-width: none; padding: 0; }
  .card, .course, .roster-sec {
    box-shadow: none;
    border: 1px solid #bbb;
    break-inside: avoid;
  }
  .print-only { display: block !important; }
  .print-head {
    margin-block-end: 10px;
    padding-block-end: 6px;
    border-block-end: 2px solid #000;
  }
  .grid-wrap { overflow: visible; }
  .timeline { min-width: 0; }
  .tl-day { background-color: #fff; }
  .tl-item { box-shadow: none; border-color: #888; background: #f2f2f2; }
  table.data thead th { position: static; background: #f2f2f2; }
  a { text-decoration: none; color: #000; }
}
.print-only { display: none; }
