body { direction: rtl; text-align: right; }
.book-reader { display: grid; gap: .75rem; }
.text-unit { background: #fff; border: 1px solid #e5e7eb; border-radius: .75rem; padding: 1rem; }
.text-unit.selected-start { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.text-unit.selected-end { border-color: #b91c1c; box-shadow: 0 0 0 3px rgba(185,28,28,.12); }
.unit-meta { color: #64748b; font-size: .9rem; margin-bottom: .5rem; }
.unit-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.selected-excerpt { white-space: pre-wrap; background: #f8fafc; border-radius: .5rem; padding: 1rem; }
.card h1, .card h2 { margin-top: 0; }

:root {
  --portal-bg: #f5f7fb;
  --portal-card: #ffffff;
  --portal-text: #182335;
  --portal-muted: #64748b;
  --portal-primary: #2563eb;
  --portal-primary-dark: #1d4ed8;
  --portal-soft: #eff6ff;
  --portal-border: #e2e8f0;
  --portal-success: #059669;
  --portal-warning: #d97706;
  --portal-danger: #dc2626;
  --portal-radius: 22px;
}

.portal-body, .login-body {
  min-height: 100vh;
  background: radial-gradient(circle at top right, #e0f2fe 0, transparent 28rem), var(--portal-bg);
  color: var(--portal-text);
  font-family: Tahoma, Arial, sans-serif;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--portal-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 44px);
}
.portal-brand { display: flex; align-items: center; gap: 12px; color: var(--portal-text); text-decoration: none; }
.brand-mark, .login-logo { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; color: white; background: linear-gradient(135deg, #2563eb, #0f766e); font-weight: 800; }
.portal-brand small { display: block; color: var(--portal-muted); font-size: 12px; margin-top: 2px; }
.portal-user { display: flex; align-items: center; gap: 12px; color: var(--portal-muted); }
.btn-linklike { border: 0; background: transparent; color: var(--portal-primary); padding: 0; cursor: pointer; }

.portal-shell { max-width: 1180px; margin: 0 auto; padding: 28px 18px 96px; }
.hero-card, .section-card, .stat-card, .action-card, .class-card, .quick-card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
}
.hero-card { padding: clamp(20px, 4vw, 34px); display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.compact-hero { padding: 20px 24px; }
.hero-card h1 { margin: 6px 0 8px; font-size: clamp(24px, 4vw, 38px); font-weight: 800; }
.hero-card p { margin: 0; color: var(--portal-muted); line-height: 1.9; }
.eyebrow { color: var(--portal-primary); font-weight: 700; letter-spacing: -.2px; }
.date-pill, .status-chip { background: var(--portal-soft); color: var(--portal-primary-dark); border-radius: 999px; padding: 8px 14px; white-space: nowrap; font-size: 13px; }
.status-chip.success { background: #ecfdf5; color: var(--portal-success); }
.status-chip.warning { background: #fffbeb; color: var(--portal-warning); }
.status-chip.danger { background: #fef2f2; color: var(--portal-danger); }

.btn-main, .btn-soft, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; padding: 11px 16px; text-decoration: none; border: 0; cursor: pointer; font-weight: 700;
}
.btn-main { background: var(--portal-primary); color: white; box-shadow: 0 10px 20px rgba(37,99,235,.20); }
.btn-main:hover { background: var(--portal-primary-dark); color: white; }
.btn-soft { background: var(--portal-soft); color: var(--portal-primary-dark); }
.btn-ghost { background: #f8fafc; color: #334155; border: 1px solid var(--portal-border); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-grid-compact { grid-template-columns: repeat(4, 1fr); }
.stat-card { padding: 20px; }
.stat-card span { display: block; color: var(--portal-muted); margin-bottom: 8px; }
.stat-card strong { font-size: 24px; }
.stat-card.success strong { color: var(--portal-success); }
.stat-card.warning strong { color: var(--portal-warning); }
.stat-card.danger strong { color: var(--portal-danger); }

.section-card { padding: 20px; margin-bottom: 22px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title h2 { margin: 0; font-size: 20px; font-weight: 800; }
.section-title p { margin: 4px 0 0; color: var(--portal-muted); }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.action-card { padding: 18px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.action-icon { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: #f8fafc; font-size: 24px; }
.action-card h3 { margin: 0 0 4px; font-size: 18px; }
.action-card p { margin: 0; color: var(--portal-muted); }
.action-buttons { display: flex; gap: 8px; }

.setup-list { display: grid; gap: 10px; }
.setup-item { display: flex; align-items: center; gap: 10px; padding: 12px; background: #f8fafc; border-radius: 16px; color: #475569; }
.setup-check { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; background: #e2e8f0; font-weight: 800; }
.setup-item.done { color: var(--portal-success); background: #ecfdf5; }
.setup-item.done .setup-check { background: var(--portal-success); color: white; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.mini-list { display: grid; gap: 10px; }
.mini-item { display: block; padding: 14px; border: 1px solid var(--portal-border); border-radius: 16px; background: #fff; text-decoration: none; color: inherit; }
.mini-item strong { display: block; margin-bottom: 6px; }
.mini-item span, .mini-item small { color: var(--portal-muted); }
.link-item:hover { border-color: #bfdbfe; background: #f8fbff; }
.danger-line { border-right: 4px solid var(--portal-danger); }
.empty-state { color: var(--portal-muted); padding: 16px; background: #f8fafc; border-radius: 16px; text-align: center; }
.empty-state.big { padding: 36px 16px; }

.class-card-list { display: grid; gap: 14px; }
.class-card { padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.class-card h3 { margin: 10px 0 6px; font-size: 22px; font-weight: 800; }
.class-card p, .class-card small { color: var(--portal-muted); margin: 0; }
.time-badge { display: inline-block; background: #f1f5f9; color: #334155; border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.class-card-action { display: grid; justify-items: end; gap: 12px; min-width: 150px; }

.wizard-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.wizard-step { background: #fff; border: 1px solid var(--portal-border); border-radius: 16px; padding: 12px; color: #475569; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 8px; }
.wizard-step span { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; background: #e2e8f0; }
.wizard-step.active { border-color: #93c5fd; color: var(--portal-primary-dark); background: #eff6ff; }
.wizard-step.done span { background: var(--portal-success); color: white; }

.portal-form label { display: block; margin: 14px 0 7px; color: #334155; font-weight: 700; }
.form-control { border-radius: 14px; border: 1px solid var(--portal-border); padding: 10px 12px; }
.form-row-2, .range-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice-tile { cursor: pointer; }
.choice-tile input { display: none; }
.choice-tile span { display: block; text-align: center; border: 1px solid var(--portal-border); border-radius: 16px; padding: 14px; background: #fff; }
.choice-tile input:checked + span { background: var(--portal-soft); border-color: #93c5fd; color: var(--portal-primary-dark); font-weight: 800; }
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.quick-card { padding: 18px; text-decoration: none; color: inherit; }
.quick-card span { display: block; color: var(--portal-muted); margin-top: 6px; }

.attendance-form { display: grid; gap: 12px; }
.attendance-row { display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--portal-border); border-radius: 18px; background: #fff; }
.note-input { margin-top: 8px; font-size: 13px; }
.attendance-options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill-radio input { display: none; }
.pill-radio span { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--portal-border); border-radius: 999px; padding: 8px 12px; cursor: pointer; background: #fff; }
.pill-radio input:checked + span { background: #eff6ff; border-color: #93c5fd; color: var(--portal-primary-dark); font-weight: 800; }
.late-input { width: 86px; border: 1px solid var(--portal-border); border-radius: 999px; padding: 8px 10px; }
.sticky-submit { position: sticky; bottom: 88px; width: 100%; }
.sticky-range-panel { position: sticky; top: 88px; z-index: 10; }
.range-status { display: flex; flex-wrap: wrap; gap: 12px; color: var(--portal-muted); margin: 14px 0; }
.portal-reader .text-unit { font-size: 17px; line-height: 2.15; }

.timeline { display: grid; gap: 14px; }
.timeline-item { border-right: 3px solid #bfdbfe; padding: 4px 14px 12px; }
.timeline-item p { margin: 8px 0; }
.case-summary p { margin: 0 0 10px; color: #475569; }

.message-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.portal-alert { padding: 12px 16px; border-radius: 16px; background: #eff6ff; color: var(--portal-primary-dark); border: 1px solid #bfdbfe; }
.portal-alert-success { background: #ecfdf5; color: var(--portal-success); border-color: #a7f3d0; }
.portal-alert-error, .portal-alert-danger { background: #fef2f2; color: var(--portal-danger); border-color: #fecaca; }

.bottom-nav { position: fixed; z-index: 30; bottom: 14px; right: 50%; transform: translateX(50%); width: min(680px, calc(100% - 28px)); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border: 1px solid var(--portal-border); box-shadow: 0 18px 40px rgba(15,23,42,.16); border-radius: 22px; display: grid; grid-auto-flow: column; overflow: hidden; }
.bottom-nav a { text-align: center; padding: 13px 8px; color: #475569; text-decoration: none; font-weight: 700; font-size: 14px; }
.bottom-nav a.active { color: var(--portal-primary-dark); background: var(--portal-soft); }

.login-body { display: grid; place-items: center; padding: 18px; }
.login-card { width: min(420px, 100%); background: rgba(255,255,255,.94); border: 1px solid var(--portal-border); border-radius: 28px; box-shadow: 0 20px 50px rgba(15,23,42,.12); padding: 28px; }
.login-logo { margin: 0 auto 16px; font-size: 24px; }
.login-card h1 { font-size: 24px; text-align: center; margin: 0 0 8px; }
.login-card p { text-align: center; color: var(--portal-muted); margin-bottom: 20px; }
.login-admin-link { display: block; text-align: center; margin-top: 16px; color: var(--portal-muted); text-decoration: none; font-size: 13px; }

@media (max-width: 860px) {
  .hero-card, .class-card, .section-title { align-items: stretch; flex-direction: column; }
  .stat-grid, .stat-grid-compact, .card-grid, .two-col, .quick-grid, .choice-grid { grid-template-columns: 1fr; }
  .action-card { grid-template-columns: auto 1fr; }
  .action-buttons { grid-column: 1 / -1; }
  .class-card-action { justify-items: stretch; min-width: 0; }
  .attendance-row { grid-template-columns: 1fr; }
  .form-row-2, .range-panel-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .portal-shell { padding: 18px 12px 104px; }
  .portal-topbar { height: 64px; padding: 0 12px; }
  .bottom-nav { bottom: 8px; width: calc(100% - 16px); }
  .bottom-nav a { font-size: 12px; padding: 12px 4px; }
  .sticky-range-panel { top: 72px; }
}

/* Jalali calendar / holiday UI */
.today-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
  font-size: .92rem;
}
.holiday-chip {
  display: inline-flex;
  align-items: center;
  padding: .4rem .75rem;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-weight: 700;
}
.holiday-chip.closed {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.holiday-notice {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  border-radius: 20px;
  background: linear-gradient(135deg, #fff7ed, #fffbeb);
  border: 1px solid #fed7aa;
  color: #92400e;
}
.holiday-notice.closed {
  background: linear-gradient(135deg, #fef2f2, #fff7ed);
  border-color: #fecaca;
  color: #991b1b;
}
.jalali-input,
.jalali-date-input {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (max-width: 640px) {
  .today-strip, .holiday-notice {
    align-items: stretch;
    flex-direction: column;
  }
  .holiday-chip {
    justify-content: center;
    text-align: center;
  }
}

/* Manager dashboard v4: base data vs term workspace */
.setup-zone {
  border: 1px solid rgba(15, 23, 42, .08);
}
.base-zone {
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.94));
}
.term-zone {
  background: linear-gradient(180deg, rgba(239,246,255,.72), rgba(255,255,255,.96));
}
.term-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 18px;
  padding: 8px 10px;
  min-width: min(360px, 100%);
}
.term-picker label {
  color: var(--portal-muted);
  font-weight: 800;
  white-space: nowrap;
}
.term-picker select {
  width: 100%;
  border: 0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  font-weight: 700;
  color: #0f172a;
}
.selected-term-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}
.selected-term-banner span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.compact-card-grid .clean-card {
  min-height: 122px;
}
.clean-card small {
  display: block;
  margin-top: 5px;
  color: #64748b;
  line-height: 1.7;
}
.primary-card {
  border: 1px solid #bfdbfe;
  background: linear-gradient(135deg, #ffffff, #eff6ff);
}
.primary-card .action-icon {
  background: #dbeafe;
}
.location-schedule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.location-card {
  margin-bottom: 0;
}
.slim-title {
  align-items: center;
}
.schedule-line strong {
  color: #0f172a;
}
.schedule-line span,
.schedule-line small {
  display: block;
  margin-top: 5px;
}
@media (max-width: 860px) {
  .term-picker {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }
  .location-schedule-grid {
    grid-template-columns: 1fr;
  }
}

/* v4.1 discussion group workspace */
.discussion-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.discussion-group-card {
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15,23,42,.05);
}
.discussion-group-card h3 {
  margin: 8px 0 6px;
  font-weight: 900;
  font-size: 20px;
}
.discussion-group-card p {
  color: var(--portal-muted);
  margin: 0 0 12px;
}
.discussion-code {
  display: inline-flex;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 800;
  font-size: 12px;
}
.member-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--portal-border);
  padding: 6px 10px;
  color: #334155;
  font-size: 13px;
}
.member-chip.muted { color: var(--portal-muted); }
.discussion-form {
  display: grid;
  gap: 16px;
}
.students-box {
  border: 1px solid var(--portal-border);
  border-radius: 20px;
  background: #fff;
  padding: 16px;
}
.student-search { margin-bottom: 12px; }
.student-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 4px;
}
.student-check {
  cursor: pointer;
  margin: 0;
}
.student-check input { display: none; }
.student-check span {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--portal-border);
  border-radius: 14px;
  background: #f8fafc;
  color: #334155;
  transition: .15s ease;
}
.student-check input:checked + span {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
  font-weight: 800;
}
.switch-line {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 4px !important;
}
.muted-help {
  display: block;
  margin-top: 6px;
  color: var(--portal-muted);
}
@media (max-width: 860px) {
  .discussion-group-grid,
  .student-check-grid { grid-template-columns: 1fr; }
}

/* v4.2 daily attendance workspace */
.daily-filter-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.daily-filter-form label { font-weight: 800; color: #334155; }
.daily-filter-form select,
.daily-filter-form input {
  border: 1px solid var(--portal-border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  min-height: 46px;
}
.manager-daily-list .class-card { align-items: stretch; }
.daily-class-card.done { border-color: #86efac; background: linear-gradient(90deg, #ffffff, #f0fdf4); }
.daily-status-box {
  min-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
}
.daily-stats-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.daily-stats-mini span {
  display: inline-flex;
  border: 1px solid var(--portal-border);
  background: #f8fafc;
  border-radius: 999px;
  padding: 5px 9px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}
.daily-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}
.attendance-form .attendance-row {
  border: 1px solid var(--portal-border);
  border-radius: 20px;
  padding: 14px;
  background: #fff;
  margin-bottom: 12px;
  box-shadow: 0 8px 18px rgba(15,23,42,.04);
}
.attendance-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.pill-radio input { display: none; }
.pill-radio span {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--portal-border);
  background: #f8fafc;
  padding: 9px 12px;
  font-weight: 800;
  color: #334155;
}
.pill-radio input:checked + span {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}
.late-input {
  width: 86px;
  border: 1px solid var(--portal-border);
  border-radius: 14px;
  padding: 9px;
}
.note-input { margin-top: 8px; }
@media (max-width: 860px) {
  .daily-filter-form { grid-template-columns: 1fr; }
  .daily-status-box { min-width: 100%; }
  .daily-actions .btn-main,
  .daily-actions .btn-ghost,
  .daily-actions button { width: 100%; justify-content: center; text-align: center; }
}

/* v4.4 precise book range reader */
.declared-range-note,
.previous-range-note {
  border-inline-start: 5px solid #3b82f6;
  background: #f8fbff;
}
.previous-range-note { border-inline-start-color: #10b981; }
.precise-range-form .sticky-range-panel {
  position: sticky;
  top: 74px;
  z-index: 5;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .08);
}
.range-actions-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
.range-actions-toolbar button.active-mode {
  outline: 3px solid rgba(37, 99, 235, .16);
  transform: translateY(-1px);
}
.precise-range-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.precise-range-status span {
  background: #f8fafc;
  border: 1px solid var(--portal-border);
  border-radius: 16px;
  padding: 10px 12px;
}
.book-reader-shell { padding: 0; overflow: hidden; }
.book-reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--portal-border);
  background: linear-gradient(90deg, #ffffff, #f8fbff);
}
.book-reader-topbar small { display: block; color: #64748b; margin-top: 4px; }
.book-search-box {
  display: flex;
  gap: 8px;
  min-width: min(100%, 420px);
}
.reader-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--portal-border);
  background: #f8fafc;
}
.reader-nav-row.bottom { border-top: 1px solid var(--portal-border); border-bottom: 0; }
.dynamic-book-reader {
  max-height: 68vh;
  overflow: auto;
  padding: 16px;
  scroll-behavior: smooth;
}
.precise-text-unit {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.precise-text-unit.is-heading {
  background: linear-gradient(90deg, #eef6ff, #ffffff);
  border-color: #bfdbfe;
  padding: 12px 16px;
}
.unit-heading-title {
  font-weight: 950;
  color: #0f172a;
  font-size: 1.12rem;
}
.precise-unit-text {
  font-size: 1.08rem;
  line-height: 2.35;
  color: #111827;
  text-align: justify;
}
.word-token {
  cursor: pointer;
  border-radius: 7px;
  padding: 1px 2px;
  transition: background .08s, color .08s;
}
.word-token:hover { background: #dbeafe; }
.word-token.in-selected-range { background: #fde68a; color: #111827; }
.word-token.range-start-word { background: #22c55e; color: #fff; }
.word-token.range-end-word { background: #ef4444; color: #fff; }
.precise-text-unit.selected-start { border-inline-start: 5px solid #22c55e; }
.precise-text-unit.selected-end { border-inline-end: 5px solid #ef4444; }
@media (max-width: 760px) {
  .precise-range-form .sticky-range-panel { position: static; }
  .book-reader-topbar, .book-search-box, .range-actions-toolbar { flex-direction: column; align-items: stretch; }
  .precise-range-status { grid-template-columns: 1fr; }
  .dynamic-book-reader { max-height: none; overflow: visible; padding: 10px; }
  .precise-unit-text { font-size: 1rem; line-height: 2.15; }
}

/* v4.5 book source and term range workspace */
.source-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin-top:14px}.source-card{border:1px solid var(--border,#d8e2ef);border-radius:18px;padding:14px;background:#fff;display:flex;flex-direction:column;gap:6px}.source-card.has-error{border-color:#fecaca;background:#fff7f7}.source-card small{color:#64748b;direction:ltr;text-align:left}.badge{display:inline-flex;align-items:center;width:max-content;border-radius:999px;padding:4px 10px;font-size:.82rem}.badge.ok{background:#dcfce7;color:#166534}.badge.warn{background:#fef3c7;color:#92400e}.badge.danger{background:#fee2e2;color:#991b1b}.badge.soft{background:#eff6ff;color:#1d4ed8}.source-link-list{display:flex;flex-direction:column;gap:12px}.source-link-row{display:grid;grid-template-columns:minmax(220px,1fr) minmax(260px,1.2fr) auto auto auto;gap:10px;align-items:center;border:1px solid #e2e8f0;border-radius:18px;padding:12px;background:#fff}.source-book-info{display:flex;flex-direction:column;gap:5px}.checkbox-inline{font-size:.86rem;color:#475569;white-space:nowrap}.offering-range-list{display:flex;flex-direction:column;gap:14px}.offering-range-card{display:flex;justify-content:space-between;gap:18px;align-items:center;background:#fff;border:1px solid #dbe6f3;border-radius:22px;padding:16px;box-shadow:0 8px 28px rgba(15,23,42,.05)}.range-card-main{display:flex;flex-direction:column;gap:6px}.range-card-main small{color:#64748b}.range-card-actions{display:flex;gap:8px;flex-wrap:wrap}.range-plan-ok{margin-top:4px;color:#047857;background:#ecfdf5;border-radius:14px;padding:8px 10px}.range-plan-warn{margin-top:4px;color:#92400e;background:#fffbeb;border-radius:14px;padding:8px 10px}code{background:#eef2ff;border-radius:8px;padding:2px 6px;direction:ltr;display:inline-block}@media(max-width:850px){.source-link-row{grid-template-columns:1fr}.offering-range-card{flex-direction:column;align-items:stretch}.range-card-actions a,.range-card-actions button{width:100%;text-align:center}.book-search-box{width:100%}}


/* =======================
   v4.12 UI polish layer
   هدف: خواناتر، زیباتر، منظم‌تر
   ======================= */

:root {
  --portal-bg: #f3f7fc;
  --portal-bg-2: #edf4ff;
  --portal-card: rgba(255,255,255,.94);
  --portal-text: #132238;
  --portal-title: #0f172a;
  --portal-muted: #66758d;
  --portal-primary: #2563eb;
  --portal-primary-dark: #1d4ed8;
  --portal-primary-soft: #eaf2ff;
  --portal-secondary: #0f766e;
  --portal-border: #dbe4f0;
  --portal-border-2: #cdd9e8;
  --portal-success: #059669;
  --portal-warning: #d97706;
  --portal-danger: #dc2626;
  --portal-shadow: 0 18px 40px rgba(15, 23, 42, .07);
  --portal-shadow-soft: 0 8px 20px rgba(15, 23, 42, .05);
  --portal-radius: 24px;
}

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body,
.portal-body,
.login-body,
.portal-form,
.form-control,
input,
select,
textarea,
button {
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
}

body {
  background:
    radial-gradient(circle at top right, rgba(147, 197, 253, .34) 0, transparent 22rem),
    radial-gradient(circle at left bottom, rgba(191, 219, 254, .24) 0, transparent 20rem),
    linear-gradient(180deg, var(--portal-bg-2), var(--portal-bg));
  color: var(--portal-text);
  line-height: 1.75;
}

h1, h2, h3, h4, h5, h6,
.hero-card h1,
.section-title h2,
.action-card h3,
.class-card h3,
.quick-card h3,
.portal-form label,
.portal-brand strong {
  color: var(--portal-title);
  letter-spacing: -.2px;
}

small,
.muted,
.muted-text,
.portal-brand small,
.hero-card p,
.section-title p,
.action-card p,
.class-card p,
.class-card small,
.empty-state,
.source-book-info small,
.source-card small {
  color: var(--portal-muted) !important;
}

.portal-topbar {
  box-shadow: 0 10px 30px rgba(15,23,42,.04);
  background: rgba(255,255,255,.80);
  border-bottom: 1px solid rgba(219,228,240,.86);
}

.portal-shell {
  max-width: 1240px;
  padding-top: 30px;
}

.hero-card,
.section-card,
.stat-card,
.action-card,
.class-card,
.quick-card,
.source-card,
.offering-range-card,
.discussion-group-card,
.students-box,
.login-card {
  background: var(--portal-card);
  border: 1px solid var(--portal-border);
  box-shadow: var(--portal-shadow-soft);
}

.hero-card,
.section-card,
.stat-card,
.action-card,
.class-card,
.quick-card,
.source-card,
.offering-range-card,
.discussion-group-card,
.students-box,
.source-link-row {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.hero-card:hover,
.section-card:hover,
.stat-card:hover,
.action-card:hover,
.class-card:hover,
.quick-card:hover,
.source-card:hover,
.offering-range-card:hover,
.discussion-group-card:hover,
.source-link-row:hover {
  border-color: #bfd2ec;
  box-shadow: var(--portal-shadow);
}

.hero-card h1 { line-height: 1.35; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  background: var(--portal-primary-soft);
  color: var(--portal-primary-dark);
  border-radius: 999px;
  padding: 8px 12px;
}

.date-pill, .status-chip, .time-badge, .badge, .discussion-code, .member-chip { font-weight: 700; }

.btn-main, .btn-soft, .btn-ghost {
  min-height: 44px;
  border-radius: 15px;
  font-size: 14px;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.btn-main:hover, .btn-soft:hover, .btn-ghost:hover { transform: translateY(-1px); }
.btn-ghost:hover { background: #fff; border-color: #bfd2ec; }

.section-card { padding: 22px; border-radius: 26px; }
.section-card > h2 { font-size: 22px; font-weight: 900; margin-bottom: 10px; }

.setup-item,
.mini-item,
.quick-card,
.action-card,
.class-card,
.attendance-form .attendance-row,
.discussion-group-card,
.students-box,
.source-link-row,
.source-card,
.offering-range-card { border-radius: 20px; }

.setup-item { border: 1px solid #edf2f7; }

.action-icon {
  background: linear-gradient(180deg, #f8fbff, #f1f7ff);
  border: 1px solid #e4eefc;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.portal-alert {
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--portal-border);
  background: #fff;
  box-shadow: var(--portal-shadow-soft);
}
.portal-alert-success { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.portal-alert-error, .portal-alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.portal-alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.portal-alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

.today-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: rgba(255,255,255,.75);
  border: 1px solid var(--portal-border);
  border-radius: 18px;
  padding: 10px 14px;
}

.portal-form label { margin-bottom: 8px; font-size: 14px; }

.form-control,
.portal-form input[type="text"],
.portal-form input[type="password"],
.portal-form input[type="number"],
.portal-form select,
.portal-form textarea,
.daily-filter-form select,
.daily-filter-form input,
.book-search-box input,
.book-search-box select,
.student-search {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--portal-border);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  color: var(--portal-text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85);
  padding: 11px 14px;
}

textarea.form-control,
.portal-form textarea { min-height: 120px; resize: vertical; }

.form-control:focus,
.portal-form input:focus,
.portal-form select:focus,
.portal-form textarea:focus,
.daily-filter-form select:focus,
.daily-filter-form input:focus,
.student-search:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37,99,235,.10);
  outline: 0;
}

select[multiple].form-control,
.source-link-row select[multiple],
.students-box select[multiple] { min-height: 180px; }
select[multiple].form-control,
.source-link-row select[multiple] { padding: 10px; line-height: 1.8; }
select[multiple] option, select option { padding: 8px 10px; }

.source-grid { gap: 16px; }
.source-card { padding: 18px; }
.source-card b { font-size: 18px; line-height: 1.6; }
.source-card .badge { margin-top: 4px; }

.source-link-list { gap: 16px; }
.source-link-row {
  grid-template-columns: minmax(220px,1.05fr) minmax(320px,1.35fr) auto auto auto;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff, #fcfdff);
}
.source-book-info { gap: 8px; }
.source-book-info b { font-size: 20px; font-weight: 900; line-height: 1.6; }
.volume-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fbff;
  border: 1px solid var(--portal-border);
  border-radius: 14px;
  padding: 10px 12px;
}

.quick-card,
.action-card,
.class-card,
.discussion-group-card,
.offering-range-card {
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(250,252,255,.95));
}
.quick-card h3,
.action-card h3,
.class-card h3,
.discussion-group-card h3 { font-weight: 900; }
.class-card h3 { font-size: 21px; }

.mini-item,
.link-item,
.quick-card,
.action-card,
.class-card,
.source-card,
.offering-range-card { text-decoration: none; }

.bottom-nav {
  position: fixed;
  right: 50%;
  transform: translateX(50%);
  bottom: 16px;
  z-index: 30;
  display: inline-flex;
  gap: 4px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--portal-border);
  border-radius: 999px;
  box-shadow: 0 18px 38px rgba(15,23,42,.14);
  padding: 8px;
  backdrop-filter: blur(12px);
}
.bottom-nav a {
  min-width: 108px;
  border-radius: 999px;
  padding: 12px 16px;
  color: #475569;
  text-decoration: none;
  font-weight: 800;
  text-align: center;
}
.bottom-nav a.active {
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  color: var(--portal-primary-dark);
}

.login-card {
  width: min(100%, 450px);
  margin: 8vh auto;
  border-radius: 28px;
  padding: 30px 28px;
  text-align: right;
  box-shadow: 0 20px 50px rgba(15,23,42,.10);
}
.login-card h1 { margin: 16px 0 8px; font-size: 28px; font-weight: 900; }
.login-card p { color: var(--portal-muted); }
.login-admin-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--portal-primary-dark);
  text-decoration: none;
  font-weight: 800;
}

.book-reader-shell,
.precise-text-unit,
.students-box,
.daily-class-card.done { box-shadow: var(--portal-shadow-soft); }

.book-reader-topbar,
.reader-nav-row,
.precise-text-unit,
.source-link-row,
.source-card,
.source-book-info,
.discussion-group-card,
.students-box { border-color: var(--portal-border); }

code {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 3px 7px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.4); }

@media (max-width: 860px) {
  .source-link-row { grid-template-columns: 1fr; padding: 14px; }
  .source-book-info b { font-size: 18px; }
  .portal-shell { padding-inline: 14px; }
  .bottom-nav {
    width: calc(100% - 24px);
    justify-content: space-between;
    gap: 6px;
  }
  .bottom-nav a {
    min-width: auto;
    flex: 1;
    padding-inline: 10px;
    font-size: 13px;
  }
  .login-card { margin: 4vh 12px; width: auto; }
}


/* v4.14 manager dashboard grouping */
.management-zone {
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.96)),
    radial-gradient(circle at top left, rgba(37,99,235,.08), transparent 20rem);
}
.management-zone .eyebrow {
  background: #ecfdf5;
  color: #047857;
}
.term-zone .eyebrow {
  background: #eef2ff;
  color: #4338ca;
}
.base-zone .eyebrow {
  background: #eff6ff;
  color: #1d4ed8;
}
.primary-card {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}
.selected-term-banner {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.selected-term-banner span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 9px 14px;
}
.term-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 18px;
  padding: 8px 10px;
}
.term-picker label {
  margin: 0;
  color: var(--portal-muted);
  font-weight: 800;
}
.term-picker select {
  border: 0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 260px;
  font-weight: 800;
  color: #0f172a;
}
@media (max-width: 860px) {
  .term-picker {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .term-picker select {
    min-width: 0;
    width: 100%;
  }
}


/* v4.15 course session plan infrastructure */
.course-plan-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}
.course-plan-mini span,
.session-plan-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--portal-border);
  background: #f8fbff;
  border-radius: 14px;
  padding: 7px 10px;
  color: #475569;
  font-size: 13px;
}
.session-plan-settings { margin-top: 14px; }
.session-auto-line { width: 100%; justify-content: flex-start; }
.session-plan-list-card { margin-top: 18px; }
.session-plan-list {
  display: grid;
  gap: 10px;
}
.session-plan-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  background: #fff;
  font-size: 14px;
}
.session-plan-row b { color: #1d4ed8; }
.planned-session-note {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}
.planned-session-range-note {
  border-inline-start-color: #7c3aed;
  background: #fbfaff;
}
@media (max-width: 760px) {
  .session-plan-row { grid-template-columns: 1fr; }
}


/* v4.16 CSV import/export for course session plans */
.csv-tools-card {
  border-color: #bfdbfe;
  background:
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,251,255,.98)),
    radial-gradient(circle at top left, rgba(37,99,235,.08), transparent 18rem);
}
.csv-import-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.csv-import-form label {
  margin: 0 0 8px;
  font-weight: 800;
}
.csv-import-form .checkbox-inline {
  align-self: center;
  margin-top: 28px;
}
.csv-import-form button {
  align-self: center;
  margin-top: 28px;
}
@media (max-width: 860px) {
  .csv-import-form {
    grid-template-columns: 1fr;
  }
  .csv-import-form .checkbox-inline,
  .csv-import-form button {
    margin-top: 0;
    width: 100%;
    justify-content: center;
  }
}

/* v4.20 book source page polish */
.book-lab-hero { background: radial-gradient(circle at top left, rgba(37,99,235,.10), transparent 22rem), rgba(255,255,255,.94); }
.book-lab-section { overflow: hidden; }
.source-grid-pro { grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 14px; }
.source-card-pro { min-height: 170px; display: grid; align-content: space-between; gap: 10px; padding: 18px; border-radius: 22px; background: linear-gradient(180deg,#fff,#f8fbff); border: 1px solid #dbeafe; box-shadow: 0 16px 34px rgba(15,23,42,.06); }
.source-card-head { display: flex; gap: 12px; align-items: flex-start; }
.source-card-head b { display: block; font-size: 17px; line-height: 1.6; color: #0f172a; }
.source-card-head small { display: block; color: #64748b; direction: ltr; text-align: right; margin-top: 4px; }
.book-mini-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; background: #eff6ff; }
.source-author { min-height: 22px; }
.source-badges { display:flex; flex-wrap:wrap; gap:6px; }
.book-connect-list { display: grid; gap: 16px; }
.book-connect-card { display: grid; grid-template-columns: minmax(260px, 1.1fr) minmax(320px, 1fr) auto; gap: 18px; align-items: center; padding: 18px; border: 1px solid var(--portal-border); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 18px 40px rgba(15,23,42,.06); }
.book-connect-card.connected { border-color: #bfdbfe; background: linear-gradient(180deg,#fff,#f8fbff); }
.book-connect-main { display:flex; align-items:flex-start; gap:14px; min-width:0; }
.book-cover-mark { width:58px; height:70px; flex:0 0 58px; display:grid; place-items:center; border-radius:18px; background: linear-gradient(135deg,#eff6ff,#ecfdf5); border:1px solid #dbeafe; font-size:27px; box-shadow: inset 0 -12px 20px rgba(37,99,235,.05); }
.book-connect-info h3 { margin:0 0 6px; font-size: 20px; font-weight: 900; line-height: 1.55; color:#0f172a; }
.book-connect-info p { margin:0 0 8px; color: var(--portal-muted); }
.volume-chip-pro { margin-top: 10px; display:flex; gap:7px; flex-wrap:wrap; }
.volume-chip { display:inline-flex; align-items:center; gap:5px; text-decoration:none; background:#eff6ff; border:1px solid #bfdbfe; color:#1d4ed8; border-radius:999px; padding:6px 10px; font-size:12px; font-weight:800; }
.volume-chip:hover { background:#dbeafe; color:#1e40af; }
.source-picker-panel label { display:block; font-weight:900; margin-bottom:8px; color:#334155; }
.source-picker-panel small { display:block; color:var(--portal-muted); margin-top:6px; }
.source-multi-select { min-height: 138px; border-radius: 16px; border-color:#cbd5e1; padding:8px; font-size:13px; }
.book-connect-actions { display:flex; flex-direction:column; align-items:stretch; gap:9px; min-width:160px; }
.disabled-like { opacity:.55; pointer-events:none; }
@media(max-width:1050px){ .book-connect-card { grid-template-columns:1fr; } .book-connect-actions { flex-direction:row; flex-wrap:wrap; } .book-connect-actions .btn-main,.book-connect-actions .btn-soft,.book-connect-actions .btn-ghost { flex:1 1 180px; } }
