/* Create Audit - Advanced Premium Design */
/* Reusing the same design system as CreateForm */

/* CSS Custom Properties for Design System */
:root {
  --primary-50: #fef2f2;
  --primary-100: #fee2e2;
  --primary-200: #fecaca;
  --primary-400: #f21b23;
  --primary-500: #f21b23;
  --primary-600: #d91820;
  --primary-700: #c2151d;
  
  --neutral-50: #fafafa;
  --neutral-100: #e5e5e5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #4d4d4f;
  --neutral-700: #4d4d4f;
  --neutral-800: #4d4d4f;
  --neutral-900: #4d4d4f;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 40px rgba(242, 27, 35, 0.15);
}

/* Prevent main content from stretching to full viewport (removes empty space below form) */
.main-content:has(.create-audit-container) {
  min-height: 0;
}

/* Main Container - Glassmorphism Effect */
.create-audit-container {
  padding: 2.5rem 3rem;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 1.5rem;
  box-shadow: 
    var(--shadow-xl),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.create-audit-container::-webkit-scrollbar {
  display: none;
}

/* Update Audit page: meta text (Audit ID, Opening Forms) */
.create-audit-meta-text {
  color: var(--neutral-600, #4d4d4f);
}
.update-audit-access-denied {
  padding: 2rem;
  text-align: center;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  background-color: var(--neutral-50);
}
.update-audit-access-denied-text {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--neutral-700);
}
.update-audit-form-hint {
  font-size: 0.875rem;
  color: var(--neutral-500);
}

/* Decorative Background Elements */
.create-audit-container::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(242, 27, 35, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.create-audit-container::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -10%;
  width: 300px;
  height: 180px;
  background: radial-gradient(circle, rgba(242, 27, 35, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.create-audit-container > * {
  position: relative;
  z-index: 1;
}

/* Grid Layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .create-audit-container {
    padding: 1.5rem;
    border-radius: 1rem;
  }

  .create-audit-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .create-audit-header .btn {
    width: 100%;
  }

  .create-audit-title {
    font-size: 1.5rem;
  }

  .coauditor-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .coauditor-input-group input,
  .coauditor-input-group select,
  .coauditor-input-group .btn {
    width: 100%;
    min-width: 0;
    margin-left: 0 !important;
  }

  .form-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .form-actions .btn {
    flex: 1;
    min-width: 120px;
  }
}

@media (max-width: 480px) {
  .create-audit-container {
    padding: 1rem;
  }

  .create-audit-title {
    font-size: 1.25rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

/* Header Section - Modern Styling */
.create-audit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  position: relative;
}

.create-audit-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(242, 27, 35, 0.5) 20%,
    rgba(242, 27, 35, 0.5) 80%,
    transparent 100%
  );
}

.create-audit-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--neutral-800) 0%, var(--neutral-600) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  letter-spacing: -0.03em;
  position: relative;
}

.create-audit-title::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: linear-gradient(180deg, var(--primary-500), var(--primary-600));
  border-radius: 2px;
}

/* Form Group with Floating Label Effect */
.form-group {
  margin-bottom: 1.75rem;
  position: relative;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--neutral-600);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 0.2s ease;
}

.form-group:focus-within .form-label {
  color: var(--primary-600);
}

/* Advanced Input Fields */
.form-input,
.form-textarea {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid var(--neutral-200);
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  background: rgba(255, 255, 255, 0.8);
  color: var(--neutral-800);
  box-shadow: var(--shadow-sm);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--neutral-400);
  font-weight: 400;
}

.form-input:hover,
.form-textarea:hover {
  border-color: var(--neutral-300);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  background: #ffffff;
  box-shadow: 
    0 0 0 4px rgba(242, 27, 35, 0.12),
    var(--shadow-lg);
  transform: translateY(-1px);
}

/* Native <select> dropdown list: ensure option text is visible (some browsers inherit field colors). */
.create-audit-container select.form-input option {
  color: var(--neutral-800);
  background: #ffffff;
}

/* Disabled / read-only field (e.g. auditor - not editable) */
.form-input-disabled,
.form-input:disabled {
  cursor: not-allowed;
  background: var(--neutral-100);
  color: var(--neutral-600);
  border-color: var(--neutral-200);
  opacity: 0.9;
}
.form-input-disabled:hover,
.form-input:disabled:hover {
  border-color: var(--neutral-200);
  background: var(--neutral-100);
  box-shadow: var(--shadow-sm);
  transform: none;
}
.form-input-disabled:focus,
.form-input:disabled:focus {
  outline: none;
  border-color: var(--neutral-200);
  box-shadow: none;
  transform: none;
}

/* Co-Auditor Input Section */
.coauditor-input-section {
  margin-bottom: 1rem;
}

.coauditor-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.coauditor-input-group .form-input {
  min-width: 0;
}

.coauditor-input-group select.form-input {
  min-width: 180px;
}

/* Co-Auditor dropdown (hot search) */
.coauditor-dropdown-group {
  flex-wrap: wrap;
  align-items: flex-start;
}
.coauditor-select-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}
.coauditor-type-select {
  min-width: 220px;
}
.coauditor-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.coauditor-search-input {
  width: 100%;
}
.coauditor-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 2px solid var(--neutral-200);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.coauditor-dropdown-item {
  padding: 0.625rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--neutral-100);
}
.coauditor-dropdown-item:last-child {
  border-bottom: none;
}
.coauditor-dropdown-item:hover,
.coauditor-dropdown-item.selected {
  background: var(--primary-50);
  color: var(--primary-800);
}
.coauditor-dropdown-empty {
  cursor: default;
  color: var(--neutral-500);
}
.coauditor-add-new-btn {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: var(--primary-100);
  border: none;
  font-weight: 600;
  color: var(--primary-700);
  cursor: pointer;
  border-radius: 0 0 0.5rem 0.5rem;
}
.coauditor-add-new-btn:hover {
  background: var(--primary-200);
}

/* Add External Auditor modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}
.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem 2rem;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Co-Auditor List */
.coauditor-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.coauditor-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--primary-50) 0%, rgba(255, 237, 213, 0.6) 100%);
  border: 1px solid var(--primary-200);
  border-radius: 0.625rem;
  box-shadow: 0 2px 8px rgba(242, 27, 35, 0.1);
}

.coauditor-name {
  flex: 1;
  font-weight: 600;
  color: var(--neutral-800);
}

.coauditor-type-badge {
  padding: 0.25rem 0.75rem;
  background: var(--primary-500);
  color: white;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--neutral-600);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.5rem;
  transition: all 0.2s ease;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
}

.btn-remove:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  transform: scale(1.1);
}

/* Auditee dropdown */
.auditee-dropdown-group {
  position: relative;
  width: 100%;
}

.auditee-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid var(--neutral-200);
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--neutral-800);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.auditee-trigger:hover {
  border-color: var(--primary-400);
  background: #ffffff;
}

.auditee-trigger.open {
  border-color: var(--primary-500);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(242, 27, 35, 0.12);
}

.auditee-trigger-text {
  flex: 1;
  min-width: 0;
  color: inherit;
}

.auditee-trigger:not(.open) .auditee-trigger-text:empty::before,
.auditee-trigger-text {
  color: inherit;
}

.auditee-trigger-arrow {
  flex-shrink: 0;
  font-size: 0.65rem;
  color: var(--neutral-500);
  transition: transform 0.2s ease;
}

.auditee-trigger.open .auditee-trigger-arrow {
  transform: rotate(180deg);
  color: var(--primary-600);
}

/* Open above the trigger so it is not clipped by container overflow */
.auditee-dropdown-panel {
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  top: auto;
  max-height: min(320px, 60vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: white;
  border: 2px solid var(--primary-200);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.auditee-search-input-inline {
  flex-shrink: 0;
  margin: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
}

.auditee-dropdown-list {
  overflow-y: auto;
  padding: 0.25rem;
  max-height: min(260px, 50vh);
}

.auditee-dropdown-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--neutral-800);
}

.auditee-dropdown-item:hover {
  background: var(--primary-50);
}

.auditee-dropdown-item.selected {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}

.auditee-dropdown-empty {
  padding: 1rem;
  text-align: center;
  color: var(--neutral-500);
  font-size: 0.875rem;
}

/* Auditee search input (legacy - kept for compatibility) */
.auditee-search-input {
  margin-bottom: 0.75rem;
}

.auditee-search-input::placeholder {
  color: var(--neutral-400);
}

.auditee-search-no-results {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--neutral-500);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Advanced Checkbox List - Card Style */
.checkbox-list-container {
  border: none;
  border-radius: 0.875rem;
  padding: 0.25rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(250,250,250,0.9) 100%);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.03),
    var(--shadow-sm);
  transition: all 0.3s ease;
  max-height: 300px;
  overflow-y: auto;
}

.checkbox-list-container:hover {
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.03),
    var(--shadow-md);
}

.checkbox-list-container:focus-within {
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.03),
    0 0 0 4px rgba(242, 27, 35, 0.08);
}

/* Checkbox Items - Interactive Cards */
.checkbox-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  margin: 0.25rem;
  border-radius: 0.625rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
}

.checkbox-item:hover {
  background: var(--primary-50);
  border-color: var(--primary-100);
  transform: translateX(4px);
}

.checkbox-item:has(.checkbox-input:checked) {
  background: linear-gradient(135deg, var(--primary-50) 0%, rgba(255, 237, 213, 0.6) 100%);
  border-color: var(--primary-200);
  box-shadow: 0 2px 8px rgba(242, 27, 35, 0.1);
}

.checkbox-item:has(.checkbox-input:checked):hover {
  transform: translateX(4px) scale(1.01);
}

/* Custom Checkbox */
.checkbox-input {
  appearance: none;
  -webkit-appearance: none;
  width: 1.375rem;
  height: 1.375rem;
  margin-right: 1rem;
  cursor: pointer;
  border: 2px solid var(--neutral-300);
  border-radius: 0.375rem;
  background: white;
  transition: all 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

.checkbox-input:hover {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(242, 27, 35, 0.1);
}

.checkbox-input:checked {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  border-color: var(--primary-600);
}

.checkbox-input:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.checkbox-text {
  font-size: 0.9375rem;
  color: var(--neutral-700);
  cursor: pointer;
  flex: 1;
  line-height: 1.5;
  font-weight: 500;
  transition: color 0.2s ease;
}

.checkbox-item:has(.checkbox-input:checked) .checkbox-text {
  color: var(--neutral-800);
}

/* Selection Counter - Badge Style */
.selected-count {
  margin-top: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--neutral-600);
  font-weight: 600;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--neutral-50) 0%, var(--neutral-100) 100%);
  border-radius: 2rem;
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.selected-count::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--primary-500);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.9); }
}

/* Form Actions - Premium Footer */
.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  position: relative;
}

.form-actions::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--neutral-200) 20%,
    var(--neutral-200) 80%,
    transparent 100%
  );
}

/* Button System */
.btn {
  padding: 0.875rem 2rem;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn-secondary {
  background: linear-gradient(135deg, #ffffff 0%, var(--neutral-50) 100%);
  color: var(--neutral-700);
  border: 2px solid var(--neutral-200);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, var(--neutral-50) 0%, var(--neutral-100) 100%);
  border-color: var(--neutral-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  box-shadow: 
    0 4px 14px rgba(242, 27, 35, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-400) 0%, var(--primary-500) 100%);
  box-shadow: 
    0 8px 25px rgba(242, 27, 35, 0.4),
    var(--shadow-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 
    0 4px 12px rgba(242, 27, 35, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:disabled {
  background: linear-gradient(135deg, var(--neutral-300) 0%, var(--neutral-400) 100%);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Error Message - Alert Style */
.error-message {
  padding: 1.125rem 1.5rem;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #b91c1c;
  border-radius: 0.75rem;
  border: 1px solid #fecaca;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.error-message::before {
  content: '⚠';
  font-size: 1.125rem;
}

/* Loading State */
.loading-container {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--neutral-500);
}

/* Entrance Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.create-audit-container {
  animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group {
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.15s; }
.form-group:nth-child(3) { animation-delay: 0.2s; }
.form-group:nth-child(4) { animation-delay: 0.25s; }
.form-group:nth-child(5) { animation-delay: 0.3s; }

.form-grid {
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  animation-delay: 0.1s;
}

/* Forms Tabs */
.forms-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--neutral-200);
  padding-bottom: 0;
}

.tab-button {
  padding: 0.875rem 2rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--neutral-600);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  bottom: -2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab-button:hover {
  color: var(--primary-600);
  background: var(--primary-50);
}

.tab-button.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-500);
  background: transparent;
}

.tab-button.active:hover {
  background: transparent;
}

/* Forms List Section */
.forms-list-container {
  margin-top: 1rem;
}

.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.form-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(250, 250, 250, 0.95) 100%);
  border: 2px solid var(--neutral-200);
  border-radius: 0.875rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.form-card:hover {
  border-color: var(--primary-400);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 237, 213, 0.3) 100%);
}

.form-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.form-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--neutral-800);
  margin: 0;
  flex: 1;
}

.form-card-type {
  padding: 0.25rem 0.75rem;
  background: var(--primary-100);
  color: var(--primary-700);
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-card-description {
  font-size: 0.875rem;
  color: var(--neutral-600);
  margin: 0.75rem 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.form-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--neutral-200);
}

.form-card-questions {
  font-size: 0.8125rem;
  color: var(--neutral-500);
  font-weight: 500;
}

/* Update Audit – Select audit list (card layout, latest first) */
.update-audit-list-wrap {
  margin-top: 2rem;
  width: 100%;
}

.update-audit-list-title {
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--neutral-800);
}

.update-audit-empty {
  padding: 2rem;
  text-align: center;
  color: var(--neutral-500);
}

/* Update Audit – list view (table layout) */
.update-audit-table-wrap {
  margin-top: 0.5rem;
  border-radius: 0.875rem;
  border: 2px solid var(--neutral-200);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}

.update-audit-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.update-audit-table thead {
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
}

.update-audit-table th {
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 700;
  color: var(--neutral-800);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--primary-200);
}

.update-audit-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--neutral-200);
  color: var(--neutral-700);
}

.update-audit-table tbody tr {
  transition: background 0.2s ease;
}

.update-audit-table tbody tr:hover {
  background: var(--primary-50);
}

.update-audit-table tbody tr:last-child td {
  border-bottom: none;
}

.update-audit-table-name {
  font-weight: 600;
  color: var(--neutral-800);
}

.update-audit-table-actions {
  text-align: right;
  white-space: nowrap;
}

.update-audit-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 1.25rem;
  width: 100%;
}

.update-audit-card {
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: 0.875rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.update-audit-card:hover {
  border-color: rgba(242, 27, 35, 0.4);
  box-shadow: var(--shadow-md);
}

.update-audit-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.update-audit-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neutral-800);
  margin: 0;
  flex: 1 1 100%;
  min-width: 0;
  word-break: break-word;
}

.update-audit-card-id {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--neutral-500);
}

.update-audit-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
}

.update-audit-card-row {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.update-audit-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.update-audit-card-value {
  color: var(--neutral-700);
  word-break: break-word;
}

.update-audit-card-actions {
  padding-top: 0.25rem;
  border-top: 1px solid var(--neutral-200);
  margin-top: auto;
}

.update-audit-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.update-audit-badge-open {
  background: #dbeafe;
  color: #1d4ed8;
}

.update-audit-badge-in-progress {
  background: #fef3c7;
  color: #b45309;
}

.update-audit-badge-closed {
  background: #d1fae5;
  color: #047857;
}

.update-audit-badge-unknown {
  background: var(--neutral-100);
  color: var(--neutral-600);
}

@media (max-width: 768px) {
  .update-audit-card-meta {
    grid-template-columns: 1fr;
  }
}

/* ================================ DARK THEME (night mode) ================================ */
body.night-mode .create-audit-container {
  background: rgba(58, 56, 56, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
body.night-mode .create-audit-header::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 20%, rgba(255, 255, 255, 0.2) 80%, transparent 100%);
}
body.night-mode .create-audit-title {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.85) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
body.night-mode .create-audit-title::before {
  background: linear-gradient(180deg, #f87171, #ef4444);
}
body.night-mode .create-audit-header .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
}
body.night-mode .create-audit-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}
body.night-mode .form-label {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .form-group:focus-within .form-label {
  color: #f87171;
}
body.night-mode .form-input,
body.night-mode .form-textarea,
body.night-mode .create-audit-container select.form-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
  color-scheme: dark;
}
body.night-mode .create-audit-container select.form-input option {
  background: rgba(58, 56, 56, 1);
  color: rgba(255, 255, 255, 0.95);
}
/* Disabled/read-only fields: readable in dark mode */
body.night-mode .form-input-disabled,
body.night-mode .form-input:disabled,
body.night-mode .form-textarea:disabled,
body.night-mode .create-audit-container select.form-input:disabled {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
  cursor: not-allowed;
}
body.night-mode .form-input::placeholder,
body.night-mode .form-textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
body.night-mode .form-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
}
body.night-mode .form-actions .btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}
body.night-mode .error-message {
  background: rgba(248, 113, 113, 0.15) !important;
  color: #fca5a5 !important;
  border-color: rgba(248, 113, 113, 0.4);
}
body.night-mode .forms-tabs {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}
body.night-mode .tab-button {
  color: rgba(255, 255, 255, 0.85);
}
body.night-mode .tab-button:hover {
  color: #f87171;
  background: rgba(255, 255, 255, 0.08);
}
body.night-mode .tab-button.active {
  color: #f87171;
  border-bottom-color: #f87171;
}
body.night-mode .form-card {
  background: rgba(58, 56, 56, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
}
body.night-mode .form-card:hover {
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(255, 255, 255, 0.06);
}
body.night-mode .form-card-title {
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .form-card-description,
body.night-mode .form-card-questions {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .form-card-type {
  background: rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}
body.night-mode .form-card-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .update-audit-list-title {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .update-audit-empty {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .update-audit-table-wrap {
  background: rgba(58, 56, 56, 0.6);
  border-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .update-audit-table thead {
  background: rgba(255, 255, 255, 0.1);
}
body.night-mode .update-audit-table th {
  color: rgba(255, 255, 255, 0.95);
  border-bottom-color: rgba(255, 255, 255, 0.15);
}
body.night-mode .update-audit-table td {
  color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
body.night-mode .update-audit-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}
body.night-mode .update-audit-table-name {
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .update-audit-card {
  background: rgba(58, 56, 56, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .update-audit-card:hover {
  border-color: rgba(248, 113, 113, 0.4);
}
body.night-mode .update-audit-card-title {
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .update-audit-card-id,
body.night-mode .update-audit-card-label,
body.night-mode .update-audit-card-value {
  color: rgba(255, 255, 255, 0.85);
}
body.night-mode .update-audit-card-actions {
  border-top-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .update-audit-badge-open {
  background: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}
body.night-mode .update-audit-badge-in-progress {
  background: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
}
body.night-mode .update-audit-badge-closed {
  background: rgba(52, 211, 153, 0.25);
  color: #6ee7b7;
}
body.night-mode .update-audit-badge-unknown {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

/* Update Audit page - dark mode */
body.night-mode .create-audit-meta-text {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .update-audit-access-denied {
  border-color: rgba(255, 255, 255, 0.15);
  background-color: rgba(255, 255, 255, 0.06);
}
body.night-mode .update-audit-access-denied-text {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .update-audit-form-hint {
  color: rgba(255, 255, 255, 0.65);
}

/* Auditees (optional) - dark mode */
body.night-mode .form-group:has(.auditee-dropdown-group) .form-label {
  color: #de6666;
}
body.night-mode .auditee-trigger {
  background: #464646;
  border-color: rgba(222, 102, 102, 0.9);
  color: #ffffff;
}
body.night-mode .auditee-trigger:hover {
  background: #505050;
  border-color: #de6666;
}
body.night-mode .auditee-trigger.open {
  background: #464646;
  border-color: #de6666;
  box-shadow: 0 0 0 3px rgba(222, 102, 102, 0.25);
}
body.night-mode .auditee-trigger-text {
  color: #ffffff;
}
body.night-mode .auditee-trigger-arrow {
  color: rgba(255, 255, 255, 0.85);
}
body.night-mode .auditee-trigger.open .auditee-trigger-arrow {
  color: #de6666;
}
body.night-mode .auditee-dropdown-panel {
  background: #464646;
  border-color: rgba(222, 102, 102, 0.6);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  /* Same as base: opens above trigger to avoid clipping */
  bottom: calc(100% + 0.35rem);
  top: auto;
  max-height: min(320px, 60vh);
}
body.night-mode .auditee-search-input-inline {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .auditee-search-input-inline::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
body.night-mode .auditee-dropdown-list {
  background: #464646;
}
body.night-mode .auditee-dropdown-item {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .auditee-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}
body.night-mode .auditee-dropdown-item.selected {
  background: rgba(255, 152, 0, 0.2);
  color: #ff9800;
}
body.night-mode .auditee-dropdown-empty {
  color: rgba(255, 255, 255, 0.6);
}
body.night-mode .auditee-dropdown-list::-webkit-scrollbar {
  width: 8px;
}
body.night-mode .auditee-dropdown-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}
body.night-mode .auditee-dropdown-list::-webkit-scrollbar-thumb {
  background: #9e9e9e;
  border-radius: 4px;
}
body.night-mode .auditee-dropdown-list::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}
body.night-mode .coauditor-list.auditee-list .coauditor-item.auditee-item {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
body.night-mode .coauditor-list.auditee-list .coauditor-name {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .coauditor-list.auditee-list .btn-remove {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
}
body.night-mode .coauditor-list.auditee-list .btn-remove:hover {
  background: rgba(222, 102, 102, 0.35);
  color: #fca5a5;
}

/* CO-AUDITORS (optional) - dark mode */
body.night-mode .form-group:has(.coauditor-input-section) .form-label {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .coauditor-type-select {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
  color-scheme: dark;
}
body.night-mode .coauditor-type-select option {
  background: #3a3838;
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .coauditor-search-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .coauditor-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}
body.night-mode .coauditor-dropdown {
  background: #464646;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
body.night-mode .coauditor-dropdown-item {
  color: rgba(255, 255, 255, 0.95);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
body.night-mode .coauditor-dropdown-item:hover,
body.night-mode .coauditor-dropdown-item.selected {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .coauditor-dropdown-empty {
  color: rgba(255, 255, 255, 0.6);
}
body.night-mode .coauditor-add-new-btn {
  background: rgba(242, 27, 35, 0.25);
  color: #fca5a5;
}
body.night-mode .coauditor-add-new-btn:hover {
  background: rgba(242, 27, 35, 0.35);
  color: #fecaca;
}
body.night-mode .coauditor-list:not(.auditee-list) .coauditor-item {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}
body.night-mode .coauditor-list:not(.auditee-list) .coauditor-name {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .coauditor-list:not(.auditee-list) .coauditor-type-badge {
  background: rgba(242, 27, 35, 0.9);
  color: #ffffff;
}
body.night-mode .coauditor-list:not(.auditee-list) .btn-remove {
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.1);
}
body.night-mode .coauditor-list:not(.auditee-list) .btn-remove:hover {
  background: rgba(222, 102, 102, 0.35);
  color: #fca5a5;
}
body.night-mode .coauditor-dropdown::-webkit-scrollbar {
  width: 8px;
}
body.night-mode .coauditor-dropdown::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}
body.night-mode .coauditor-dropdown::-webkit-scrollbar-thumb {
  background: #9e9e9e;
  border-radius: 4px;
}
body.night-mode .coauditor-dropdown::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}
