/* ========================================
   App Layout (Control + Admin)
   ======================================== */

.app {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  font-size: 15px;
}
.sidebar-brand .brand-text small {
  display: block;
  color: var(--sidebar-text);
  font-weight: 400;
  font-size: 11.5px;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 14px 12px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-section-label {
  padding: 12px 12px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: start;
  font-family: inherit;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}
.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
}
.nav-item .nav-badge {
  margin-inline-start: auto;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ----- Main Content ----- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  flex-shrink: 0;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title .crumb {
  color: var(--text-muted);
  font-size: 13px;
  display: none;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-toggle:hover {
  background: var(--surface-2);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.user-chip i {
  color: var(--primary);
}

.content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}

/* ----- Page Section ----- */
.page-section {
  display: none;
  animation: fadeIn 0.25s ease;
}
.page-section.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h2 {
  font-size: 22px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-head h2 i {
  color: var(--primary);
  font-size: 22px;
}
.page-head .desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.page-head .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----- KPI Cards ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.kpi-card .kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
}
.kpi-card .kpi-content {
  flex: 1;
  min-width: 0;
}
.kpi-card .kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.kpi-card .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-card.purple .kpi-icon {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
}
.kpi-card.blue .kpi-icon {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}
.kpi-card.green .kpi-icon {
  background: linear-gradient(135deg, #10b981, #14b8a6);
}
.kpi-card.orange .kpi-icon {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}
.kpi-card.pink .kpi-icon {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
}
.kpi-card.cyan .kpi-icon {
  background: linear-gradient(135deg, #06b6d4, #0ea5e9);
}

/* ----- Toolbar ----- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.toolbar .filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
}
.toolbar .filters .form-control,
.toolbar .filters .form-select {
  width: auto;
  min-width: 160px;
}

/* ----- Score Entry Grid ----- */
.score-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.score-entry-head {
  padding: 16px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.score-entry-head h4 {
  margin: 0;
}
.score-entry-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.score-entry-progress .progress-bar-wrap {
  width: 160px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.score-entry-progress .progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #14b8a6);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.score-input {
  width: 110px;
  text-align: center;
  font-weight: 700;
}
.score-input.absent {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warning-dark);
}
.score-saved {
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.score-saved.show {
  opacity: 1;
}

/* ----- Settings ----- */
.settings-card {
  max-width: 700px;
}

/* ----- Activity Feed ----- */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.activity-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:last-child {
  border-bottom: 0;
}
.activity-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary);
  flex-shrink: 0;
  font-size: 14px;
}
.activity-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}
.activity-icon.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}
.activity-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.activity-content {
  flex: 1;
  min-width: 0;
}
.activity-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.activity-desc {
  font-size: 13px;
  color: var(--text-muted);
}
.activity-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ----- Charts ----- */
.chart-grid {
  display: grid;
  gap: 18px;
}
.chart-grid.cols-2 {
  grid-template-columns: 1fr 1fr;
}
.chart-grid.cols-3 {
  grid-template-columns: 2fr 1fr;
}
@media (max-width: 1100px) {
  .chart-grid.cols-2,
  .chart-grid.cols-3 {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  min-height: 320px;
}
.chart-card .chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.chart-card .chart-head h4 {
  margin: 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-card .chart-head h4 i {
  color: var(--primary);
}
.chart-canvas {
  width: 100%;
  height: 320px;
}

/* ============================================
   HOME (Control Room Board)
   ============================================ */
.home-hero {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  isolation: isolate;
}
.home-hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 60%, #10b981 100%);
  z-index: -1;
}
.home-hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.18) 0, transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,0.12) 0, transparent 40%);
}
.home-hero-content {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 26px 30px;
  color: #fff;
  flex-wrap: wrap;
}
.home-logo {
  width: 110px;
  height: 110px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.home-titles {
  flex: 1;
  min-width: 240px;
}
.home-titles h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
}
.home-titles p {
  margin: 0;
  font-size: 14.5px;
  opacity: 0.95;
}
.home-hero-meta {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
}
.home-hero-meta span {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(6px);
}
.home-hero-meta span i {
  font-size: 12px;
}
.home-readonly-badge {
  background: rgba(245, 158, 11, 0.95) !important;
  color: #fff !important;
  font-weight: 700;
}

.home-clock-big {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 16px 22px;
  border-radius: 16px;
  text-align: center;
  min-width: 220px;
}
.home-clock-time {
  font-size: 30px;
  font-weight: 800;
  font-family: "Cairo", monospace;
  letter-spacing: 1px;
  font-feature-settings: "tnum";
  line-height: 1.1;
}
.home-clock-date {
  font-size: 13px;
  margin: 4px 0 6px;
  opacity: 0.95;
}
.home-clock-big small {
  display: block;
  font-size: 11.5px;
  opacity: 0.85;
}

/* ----- Topbar Clock ----- */
.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-feature-settings: "tnum";
  line-height: 1.2;
  min-width: 130px;
}
.topbar-clock-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-clock-time i {
  color: var(--primary);
  font-size: 12px;
}
.topbar-clock-date {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================
   CONTROL BOARD TABLE (الصورة المرفقة)
   ============================================ */
.cb-table-wrap {
  overflow-x: auto;
}
.cb-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
}
.cb-table thead th {
  background: #f8fafc;
  color: var(--text);
  font-weight: 700;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--border);
  font-size: 12.5px;
  white-space: nowrap;
}
.cb-table thead .cb-grade-th {
  background: linear-gradient(180deg, #e0f2fe, #bae6fd);
  color: #075985;
}
.cb-table thead .cb-h2 {
  background: #fff;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
}
.cb-table tbody td {
  padding: 8px 6px;
  text-align: center;
  border: 1px solid var(--border);
  vertical-align: middle;
  background: var(--surface);
}
.cb-table tbody tr:hover td {
  background: var(--surface-2);
}

.cb-day-cell {
  font-weight: 800;
  background: linear-gradient(180deg, #fef3c7, #fde68a) !important;
  color: #92400e;
}
.cb-date-cell {
  font-weight: 700;
  background: #fffbeb !important;
  color: #b45309;
}
.cb-time-cell {
  font-feature-settings: "tnum";
  font-weight: 600;
  color: var(--text);
}
.cb-subject-cell {
  font-weight: 700;
}
.cb-num-zero {
  color: #ef4444;
  font-weight: 700;
}
.cb-num {
  color: var(--text);
  font-weight: 700;
  font-feature-settings: "tnum";
}
.cb-num-blue { color: #2563eb; }

/* Per-grade column block (counts + papers) */
.cb-grade-block {
  background: linear-gradient(180deg, #fef3c7, #fde68a);
}
.cb-grade-counts {
  background: #ecfccb !important;
}
.cb-papers {
  background: #dcfce7 !important;
}
.cb-grade-rate {
  font-weight: 800;
  background: #ecfccb !important;
  color: #14532d;
  font-size: 13.5px;
}
.cb-day-rate {
  font-weight: 800;
  background: linear-gradient(180deg, #ecfdf5, #a7f3d0) !important;
  color: #065f46;
  font-size: 14px;
}

.cb-empty-cell {
  background: #f9fafb !important;
  color: var(--text-faint);
}

/* Custom checkbox in board */
.cb-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: transparent;
  transition: var(--transition);
  user-select: none;
}
.cb-check:hover {
  border-color: var(--primary);
}
.cb-check.checked {
  background: #16a34a;
  border-color: #15803d;
  color: #fff;
}
.cb-check.readonly {
  cursor: not-allowed;
  opacity: 0.95;
}
.cb-check.readonly:hover {
  border-color: inherit;
}

/* No-exams state */
.cb-empty-row td {
  padding: 30px;
  background: #f9fafb;
  color: var(--text-muted);
  font-size: 14px;
}

/* Footer (totals / day rate) */
.cb-footer-row td {
  background: linear-gradient(180deg, #ecfdf5, #d1fae5) !important;
  font-weight: 800;
  font-size: 14px;
}

/* ============================================
   ROOM LINKS GRID
   ============================================ */
.room-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.room-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  transition: var(--transition);
  position: relative;
}
.room-link-card:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.room-link-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 19px;
  flex-shrink: 0;
}
.room-link-info {
  flex: 1;
  min-width: 0;
}
.room-link-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-link-url {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: start;
}
.room-link-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.room-link-actions .room-link-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.room-link-actions .btn-icon {
  width: 34px;
  height: 34px;
}
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger-border, #fecaca);
}
.btn-danger-outline:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.room-link-empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.room-link-empty i {
  font-size: 48px;
  color: var(--text-faint);
  display: block;
  margin-bottom: 10px;
}
.room-link-empty h4 {
  margin: 0 0 6px;
  color: var(--text);
}
.room-link-empty p {
  margin: 0;
  font-size: 13px;
}

/* On smaller screens stack the actions */
@media (max-width: 540px) {
  .room-link-actions .room-link-open span {
    display: none;
  }
  .room-link-actions .room-link-open {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
}

/* ============================================
   DAILY REPORT
   ============================================ */
.dr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.dr-head {
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--primary-50), #e0f2fe);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}
.dr-head-info h3 {
  margin: 0 0 6px;
  font-size: 18px;
}
.dr-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-soft);
}
.dr-head-meta span {
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dr-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.dr-summary strong {
  font-size: 22px;
  color: var(--success-dark);
}

.dr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.dr-table thead th {
  background: var(--surface-2);
  padding: 12px;
  text-align: center;
  border-bottom: 2px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.dr-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dr-table tbody tr.dr-row-yes td {
  background: rgba(16, 185, 129, 0.08);
}
.dr-table tbody tr.dr-row-no td {
  background: rgba(239, 68, 68, 0.08);
}
.dr-item-text {
  font-weight: 600;
  color: var(--text);
}
.dr-yes-cell, .dr-no-cell {
  width: 90px;
  text-align: center;
}
.dr-check {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 14px;
  transition: var(--transition);
}
.dr-check.yes.checked {
  background: #16a34a;
  border-color: #15803d;
  color: #fff;
}
.dr-check.no.checked {
  background: #dc2626;
  border-color: #b91c1c;
  color: #fff;
}
.dr-check.readonly {
  cursor: not-allowed;
}
.dr-notes-cell {
  min-width: 220px;
}
.dr-notes-cell input,
.dr-notes-cell textarea {
  width: 100%;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  outline: none;
}
.dr-notes-cell input:focus,
.dr-notes-cell textarea:focus {
  border-color: var(--primary);
}
.dr-notes-readonly {
  font-size: 13px;
  color: var(--text-soft);
  min-height: 24px;
}

.dr-signatures {
  margin-top: 18px;
  padding: 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.dr-sig {
  text-align: center;
  font-size: 13px;
}
.dr-sig-label {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.dr-sig-line {
  border-top: 2px dashed #94a3b8;
  margin: 30px 12px 8px;
}
.dr-sig input {
  text-align: center;
}

/* ============================================
   STUDENT ANALYSIS
   ============================================ */
.sa-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.sa-student-header {
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.sa-student-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.sa-student-info {
  flex: 1;
  min-width: 200px;
}
.sa-student-info h3 {
  margin: 0 0 4px;
  color: #fff;
  font-size: 20px;
}
.sa-student-info .sa-student-meta {
  font-size: 13.5px;
  opacity: 0.9;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.sa-student-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  min-width: 280px;
}
.sa-stat {
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 12px;
  border-radius: 10px;
  text-align: center;
  backdrop-filter: blur(6px);
}
.sa-stat-label {
  font-size: 11.5px;
  opacity: 0.9;
  margin-bottom: 2px;
}
.sa-stat-value {
  font-size: 20px;
  font-weight: 800;
  font-feature-settings: "tnum";
}
.sa-stat-sub {
  font-size: 11px;
  opacity: 0.88;
  margin-top: 4px;
  line-height: 1.35;
  font-weight: 600;
}

.sa-grades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.sa-grades-table thead th {
  background: var(--surface-2);
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
}
.sa-grades-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sa-grade-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}
.sa-grade-bar-fill {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.sa-grade-bar-fill > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.4s;
}

.sa-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.sa-empty i {
  font-size: 56px;
  color: var(--text-faint);
  display: block;
  margin-bottom: 14px;
}

.sa-search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 380px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-top: 10px;
}
.sa-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  transition: var(--transition);
}
.sa-result-item:hover {
  background: var(--primary-50);
  transform: translateX(-3px);
}
.sa-result-item-info {
  flex: 1;
}
.sa-result-item-name {
  font-weight: 700;
}
.sa-result-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .page-head .actions,
  .home-clock-big,
  .login-overlay {
    display: none !important;
  }
  .content {
    padding: 0 !important;
  }
  .card,
  .dr-card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
  }
  body {
    background: #fff !important;
  }
}

/* ----- Login Overlay (Control Gate) ----- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  overflow: hidden;
}
.login-overlay[hidden] {
  display: none !important;
}

.login-bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.login-bubbles span {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  animation: loginBubble 14s linear infinite;
}
.login-bubbles span:nth-child(1) { width: 80px; height: 80px; left: 10%; top: 80%; animation-delay: 0s; }
.login-bubbles span:nth-child(2) { width: 50px; height: 50px; left: 25%; top: 90%; animation-delay: 2s; }
.login-bubbles span:nth-child(3) { width: 120px; height: 120px; left: 60%; top: 95%; animation-delay: 4s; }
.login-bubbles span:nth-child(4) { width: 65px; height: 65px; left: 78%; top: 70%; animation-delay: 1s; }
.login-bubbles span:nth-child(5) { width: 100px; height: 100px; left: 45%; top: 100%; animation-delay: 6s; }
@keyframes loginBubble {
  0% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { transform: translateY(-110vh) scale(1.4); opacity: 0; }
}

.login-card {
  position: relative;
  background: var(--surface);
  border-radius: 22px;
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  animation: loginIn 0.4s ease;
  z-index: 1;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}
.login-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.35);
}
.login-brand h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--text);
}
.login-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.login-pass-wrap {
  position: relative;
}
.login-pass-wrap .form-control {
  padding-inline-end: 44px;
}
.login-pass-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.login-pass-toggle:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-dark);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: shake 0.4s;
}
.login-error[hidden] {
  display: none !important;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.login-back {
  margin-top: 8px;
  color: var(--text-muted) !important;
}
.login-back:hover {
  color: var(--primary) !important;
}

/* ----- Score Entry: Class Groups ----- */
.score-class-group {
  border-bottom: 1px solid var(--border);
}
.score-class-group:last-child {
  border-bottom: 0;
}
.score-class-head {
  padding: 12px 18px;
  background: linear-gradient(90deg, var(--primary-50), transparent 80%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.score-class-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  flex-wrap: wrap;
}
.score-class-title i {
  color: var(--primary);
}
.score-class-title strong {
  font-size: 15px;
  color: var(--text);
}
.score-class-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.score-class-progress .progress-bar-wrap {
  width: 130px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.score-class-progress .progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #14b8a6);
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* ----- Sidebar Backdrop (Mobile) ----- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 49;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* ----- Schedule (Admin) ----- */
.schedule-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.schedule-live {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.schedule-live .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: live-pulse 1.6s infinite;
}
.schedule-upcoming {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}
.schedule-today {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}
.schedule-past {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #e5e7eb;
}
.schedule-completed {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #ddd6fe;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ----- Responsive ----- */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    transform: translateX(100%);
    height: 100vh;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-toggle {
    display: inline-flex;
  }
  .content {
    padding: 18px 16px;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 10px 14px;
  }
  .topbar-title h1 {
    font-size: 15px;
  }
  .user-chip span {
    display: none;
  }
  .conn-indicator span {
    display: none;
  }
  .page-head h2 {
    font-size: 18px;
  }
  .kpi-card .kpi-value {
    font-size: 20px;
  }
}
