.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 5, 10, 0.85);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 700px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.modal-header {
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
}

.modal-meta {
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.modal-stats {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 28px;
  overflow-y: auto;
  flex: 1;
}

.student-section-title {
  font-family: "Space Mono", monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  margin-top: 4px;
}

.student-section-title.present {
  color: var(--green);
}

.student-section-title.absent {
  color: var(--red);
}

.student-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.student-chip {
  font-family: "Space Mono", monospace;
  font-size: 11px;
  padding: 7px 12px 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.student-chip:hover {
  transform: translateY(-2px);
}

.student-chip:active {
  transform: scale(0.97);
}

.student-chip.present {
  background: rgba(108, 252, 160, 0.08);
  color: var(--green);
  border: 1px solid rgba(108, 252, 160, 0.25);
}

.student-chip.absent {
  background: rgba(252, 108, 143, 0.08);
  color: var(--red);
  border: 1px solid rgba(252, 108, 143, 0.25);
}

.student-chip.present:hover {
  background: rgba(252, 108, 143, 0.12);
  border-color: rgba(252, 108, 143, 0.4);
}

.student-chip.absent:hover {
  background: rgba(108, 252, 160, 0.12);
  border-color: rgba(108, 252, 160, 0.4);
}

.student-chip .student-name {
  display: block;
  font-family: "Syne", sans-serif;
  font-size: 10px;
  margin-top: 2px;
  opacity: 0.7;
}

.student-chip .toggle-hint {
  display: block;
  font-family: "Space Mono", monospace;
  font-size: 9px;
  margin-top: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  letter-spacing: 0.5px;
}

.student-chip:hover .toggle-hint {
  opacity: 0.8;
}

.student-chip.present .toggle-hint {
  color: var(--red);
}

.student-chip.absent .toggle-hint {
  color: var(--green);
}

.student-chip.changed::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--yellow);
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.modal-footer-left {
  font-family: "Space Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.changes-badge {
  display: inline-block;
  font-family: "Space Mono", monospace;
  font-size: 11px;
  background: rgba(252, 217, 108, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(252, 217, 108, 0.3);
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: 8px;
}

.btn-update {
  background: var(--green);
  color: #0a0a0f;
  border: none;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 11px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-update:hover {
  background: #8fffc0;
  box-shadow: 0 4px 20px rgba(108, 252, 160, 0.3);
  transform: translateY(-1px);
}

.btn-update:active {
  transform: translateY(0);
}

.btn-update:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal-feedback {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
}

.modal-feedback.error {
  background: rgba(252, 108, 143, 0.07);
  color: var(--red);
  border-left: 3px solid var(--red);
}

.modal-feedback.success {
  background: rgba(108, 252, 160, 0.07);
  color: var(--green);
  border-left: 3px solid var(--green);
}

.modal-loading {
  text-align: center;
  padding: 40px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-bottom: 10px;
}
