.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 200;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  border-radius: 0;
  background: var(--panel, #ffffff);
  border: none;
  box-shadow: none;
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 5px 24px;
  border-bottom: 1px solid var(--border, #d9dde7);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--muted, #6b7280);
}

.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted, #6b7280);
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text, #1f2430);
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  flex: 1;
}

.sheet-selection {
  margin-bottom: 24px;
  padding: 10px;
  display: flex;
  background: var(--background, #f8fafc);
  border-radius: 8px;
  border: 1px solid var(--border, #d9dde7);
}

.sheet-selection .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-selection .field span {
  font-weight: 500;
  color: var(--text-primary, #1e293b);
}

.sheet-dropdown {
  padding: 8px 12px;
  border: 1px solid var(--border, #d9dde7);
  border-radius: 6px;
  background: var(--panel, #ffffff);
  font-size: 14px;
  color: var(--text-primary, #1e293b);
  cursor: pointer;
}

.sheet-dropdown:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.mapping-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted, #6b7280);
  position: relative;
}

.mapping-grid select {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #d9dde7);
  background: #ffffff;
  color: var(--text, #1f2430);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mapping-grid select:focus {
  border-color: var(--primary, #2563eb);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.mapping-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-toggle {
  width: 100%;
  padding: 6px 28px 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border, #d9dde7);
  background: #ffffff;
  color: var(--text, #1f2430);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
  position: relative;
}

.dropdown-toggle:hover {
  border-color: var(--primary, #2563eb);
}

.dropdown-toggle:focus-visible {
  border-color: var(--primary, #2563eb);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.mapping-dropdown.is-open .dropdown-toggle {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.dropdown-toggle.is-placeholder {
  color: var(--muted, #6b7280);
}

.dropdown-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-caret {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--muted, #6b7280);
  border-bottom: 1px solid var(--muted, #6b7280);
  transform: translateY(-50%) rotate(45deg);
  transition: transform 0.2s ease;
}

.mapping-dropdown.is-open .dropdown-caret {
  transform: translateY(-50%) rotate(-135deg);
}

.dropdown-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  border-radius: 10px;
  border: 1px solid var(--border, #d9dde7);
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  z-index: 4;
}

.mapping-dropdown.is-open .dropdown-options {
  display: block;
}

.dropdown-options::-webkit-scrollbar {
  width: 6px;
}

.dropdown-options::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.dropdown-option {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text, #1f2430);
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.dropdown-option.is-empty {
  color: var(--muted, #6b7280);
}

.dropdown-option.is-highlighted {
  background: rgba(37, 99, 235, 0.12);
}

.dropdown-option.is-selected {
  font-weight: 600;
}

.column-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  transform: none;
  width: 240px;
  max-height: 220px;
  overflow: auto;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border, #d9dde7);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  z-index: 1500;
  color: var(--text, #1f2430);
}

.column-tooltip.is-visible {
  display: flex;
}

.column-tooltip strong {
  font-size: 13px;
  font-weight: 600;
}

.column-tooltip ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted, #6b7280);
  max-height: 140px;
  overflow-y: auto;
}

.column-tooltip li {
  margin-bottom: 4px;
  word-break: break-word;
}

.column-tooltip li:last-child {
  margin-bottom: 0;
}

.column-tooltip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--text, #1f2430);
}

.column-tooltip-table thead {
  background: #f1f5f9;
}

.column-tooltip-table th,
.column-tooltip-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #d9dde7);
  text-align: left;
}

.column-tooltip-table tbody tr:nth-child(odd) {
  background: #f8fafc;
}

.column-tooltip-table tbody tr:last-child td {
  border-bottom: none;
}

.column-tooltip-more {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #6b7280);
}

.modal-preview {
  border: 1px solid var(--border, #d9dde7);
  border-radius: 10px;
  background: #ffffff;
}

.modal-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.modal-preview thead .preview-actions-header {
  width: 92px;
}

.modal-preview thead {
  background: #f1f5f9;
}

.modal-preview th,
.modal-preview td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #d9dde7);
  text-align: left;
  white-space: nowrap;
}

.modal-preview tbody tr:nth-child(odd) {
  background: #f8fafc;
}

.modal-preview tbody tr.has-empty-cells {
  background: #fef2f2 !important;
  border-left: 3px solid #ef4444;
}

.modal-preview tbody tr.has-empty-cells td {
  background: #fef2f2 !important;
}

.preview-delete {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(254, 226, 226, 0.8);
  color: #b91c1c;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.preview-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.6);
  color: #991b1b;
}

.modal-footer {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border, #d9dde7);
}

.modal-footer .primary,
.modal-footer .secondary {
  min-width: 140px;
}

@media (max-width: 768px) {
  .modal {
    padding: 0;
  }

  .modal-dialog {
    width: 100vw;
    height: 100vh;
  }

  .modal-body {
    padding: 16px;
  }

  .mapping-grid {
    grid-template-columns: 1fr;
  }

  .column-tooltip {
    left: 50%;
    top: auto;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(320px, calc(100% - 32px));
  }

  .modal-preview th,
  .modal-preview td {
    white-space: normal;
  }
}

@media (max-width: 1024px) {
  .mapping-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .mapping-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Special values confirmation styles */
.special-values-confirmation {
  margin-top: 16px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.special-values-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.special-values-description {
  margin: 0 0 12px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* Data range info styles */
.data-range-info {
  margin-bottom: 16px;
  padding: 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.data-range-row {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex-wrap: wrap;
}

.data-range-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.data-range-label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

.data-range-value {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 4px;
}

.data-range-value.missing-data {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.data-range-value.no-missing {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.data-range-value.complete-data {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.data-range-value.no-complete {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.data-range-value.status-complete {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
  font-weight: 700;
}

.data-range-value.status-incomplete {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-weight: 700;
}

.special-value-field {
  margin-bottom: 8px;
  padding: 8px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.special-value-field.confirmed {
  border-color: #10b981;
  background: #f0fdf4;
}

.special-value-field.editing {
  border-color: #f59e0b;
  background: #fffbeb;
}

.special-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.special-value-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  min-width: 80px;
  flex-shrink: 0;
}

.special-value-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.special-value-display {
  flex: 1;
  padding: 4px 8px;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  font-size: 12px;
  color: #374151;
  word-break: break-word;
  min-height: 20px;
  display: flex;
  align-items: center;
}

.special-value-actions {
  display: flex;
  gap: 4px;
}

.special-value-edit {
  display: none;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.special-value-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  font-size: 12px;
  background: white;
  min-height: 20px;
}

.special-value-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.btn-correct,
.btn-wrong,
.btn-save-edit,
.btn-cancel-edit {
  padding: 4px 6px;
  border: none;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-correct {
  background: #10b981;
  color: white;
}

.btn-correct:hover {
  background: #059669;
}

.btn-wrong {
  background: #f59e0b;
  color: white;
}

.btn-wrong:hover {
  background: #d97706;
}

.btn-save-edit {
  background: #3b82f6;
  color: white;
}

.btn-save-edit:hover {
  background: #2563eb;
}

.btn-cancel-edit {
  background: #6b7280;
  color: white;
}

.btn-cancel-edit:hover {
  background: #4b5563;
}

/* School abbreviation display */
.school-abbreviation-display {
  margin-top: 12px;
  padding: 8px 12px;
  background: #e0f2fe;
  border: 1px solid #0ea5e9;
  border-radius: 4px;
  font-size: 12px;
}

.abbreviation-label {
  color: #0369a1;
  font-weight: 600;
  margin-bottom: 4px;
}

.abbreviation-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.abbreviation-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #bae6fd;
  border-radius: 3px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: #0c4a6e;
  background: white;
  min-width: 120px;
}

.abbreviation-input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

.reset-abbreviation-btn {
  padding: 4px 8px;
  border: 1px solid #f59e0b;
  border-radius: 3px;
  background: #fef3c7;
  color: #d97706;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.reset-abbreviation-btn:hover {
  background: #fde68a;
  color: #b45309;
}

/* Fixed scroll button styles */
.fixed-scroll-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  font-size: 12px;
  font-weight: 500;
  min-width: 120px;
  backdrop-filter: blur(10px);
}

.fixed-scroll-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, #2563eb, #1e40af);
}

.fixed-scroll-button:active {
  transform: translateY(0);
}

.scroll-icon {
  font-size: 16px;
  animation: bounce 2s infinite;
}

.scroll-text {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-3px);
  }
  60% {
    transform: translateY(-2px);
  }
}

/* Apply button scroll required state */
.modal-footer .primary.scroll-required {
  background: #f59e0b;
  border-color: #f59e0b;
  color: white;
  opacity: 0.8;
  cursor: not-allowed;
}

.modal-footer .primary.scroll-required:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  transform: none;
}

/* Scroll indicator styles */
.scroll-indicator {
  position: fixed;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 4px;
  height: 100px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 2px;
  z-index: 999;
  display: none;
}

.scroll-indicator .progress {
  width: 100%;
  background: linear-gradient(to bottom, #3b82f6, #1d4ed8);
  border-radius: 2px;
  transition: height 0.3s ease;
  height: 0%;
}

/* Mobile responsive for fixed button */
@media (max-width: 768px) {
  .fixed-scroll-button {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    min-width: 100px;
    font-size: 11px;
  }
  
  .scroll-icon {
    font-size: 14px;
  }
  
  .scroll-text {
    font-size: 10px;
  }
}

/* Empty data message styles */
.empty-data-message {
  text-align: center;
  color: #6b7280;
  font-style: italic;
  padding: 20px !important;
  background: #f9fafb !important;
}
