* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font: 15px/1.6 'Inter', -apple-system, system-ui, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 2rem 1rem;
}
.container {
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 2.5rem;
  text-align: center;
}
.header img {
  max-width: 180px;
  height: auto;
  margin-bottom: 1rem;
}
.header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.header p {
  font-size: 16px;
  opacity: 0.95;
}
.form-content {
  padding: 2.5rem;
}
fieldset {
  border: 2px solid #e5e7eb;
  padding: 1.5rem;
  border-radius: 12px;
  margin: 1.5rem 0;
  background: #fafbfc;
}
legend {
  font-weight: 600;
  color: #111827;
  padding: 0 0.75rem;
  font-size: 17px;
}
label {
  display: block;
  margin: 0.8rem 0;
  font-size: 14px;
  color: #374151;
}
label strong {
  color: #111827;
  display: block;
  margin-bottom: 0.4rem;
  font-size: 14px;
}
input, textarea, select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted {
  color: #6b7280;
  font-size: 13px;
  margin-top: 0.3rem;
  display: block;
}
.required { color: #ef4444; }
button.submit {
  width: 100%;
  padding: 1rem;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  margin-top: 2rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
button.submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102,126,234,0.4);
}
.hidden { display: none; }

/* Verify button styles */
.verify-btn {
  padding: 0.75rem 1.25rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s;
}
.verify-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.verify-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.verify-btn.verified {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  cursor: default;
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.6s linear infinite;
}
@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* Validation error styles */
input.error, textarea.error, select.error {
  border-color: #ef4444;
  background-color: #fef2f2;
}
input.error:focus, textarea.error:focus, select.error:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.error-message {
  color: #ef4444;
  font-size: 12px;
  display: block;
  margin-top: 4px;
  font-weight: 500;
}

/* Success validation styles */
input.valid, textarea.valid, select.valid {
  border-color: #10b981;
}
input.valid:focus, textarea.valid:focus, select.valid:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

/* Toggle switches for modules */
.module-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.module-toggle {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}
.module-toggle:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102,126,234,0.15);
}
.module-toggle.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
  color: #fff;
}
.module-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.module-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.module-name {
  font-weight: 600;
  font-size: 15px;
}
.toggle-indicator {
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  transition: background 0.3s;
}
.toggle-indicator::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
}
.module-toggle.active .toggle-indicator {
  background: #fff;
}
.module-toggle.active .toggle-indicator::after {
  background: #667eea;
  transform: translateX(20px);
}

/* Sub-modules */
.submodule-section {
  background: #eff6ff;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  border-left: 4px solid #3b82f6;
}
.submodule-section h4 {
  color: #1e40af;
  font-size: 14px;
  margin-bottom: 0.75rem;
}

/* Sub-module toggles (smaller version) */
.submodule-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.submodule-toggle {
  background: #fff;
  border: 2px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}
.submodule-toggle:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}
.submodule-toggle.active {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  border-color: #3b82f6;
  color: #fff;
}
.submodule-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.submodule-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.submodule-name {
  font-weight: 600;
  font-size: 14px;
}
.submodule-desc {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 0.15rem;
}
.submodule-toggle.active .submodule-desc {
  opacity: 0.9;
}
.submodule-toggle .toggle-indicator {
  width: 36px;
  height: 20px;
  background: #d1d5db;
  border-radius: 10px;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}
.submodule-toggle .toggle-indicator::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
}
.submodule-toggle.active .toggle-indicator {
  background: #fff;
}
.submodule-toggle.active .toggle-indicator::after {
  background: #60a5fa;
  transform: translateX(16px);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.checkbox-item input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.checkbox-item label {
  margin: 0;
  cursor: pointer;
}

/* Radio groups */
.radio-group {
  display: flex;
  gap: 1rem;
  margin: 0.75rem 0;
  flex-wrap: wrap;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  cursor: pointer;
}
.radio-group input[type="radio"] {
  width: auto;
  margin: 0;
}

.section-header {
  background: #f3f4f6;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 1.25rem 0 0.75rem;
  border-left: 4px solid #667eea;
}
.section-header h3 {
  margin: 0;
  font-size: 15px;
  color: #111827;
}

.optional-tag {
  color: #9ca3af;
  font-weight: 400;
  font-size: 13px;
  font-style: italic;
}

/* CDN Configuration */
.cdn-config {
  margin: 1rem 0;
}

/* Slider styles with visible stops */
.slider-container {
  margin: 1rem 0;
}
.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.slider-value {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  min-width: 50px;
  text-align: center;
}
.slider-wrapper {
  position: relative;
  padding: 0.5rem 0;
}
.slider-stops {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding: 0 10px;
}
.slider-stop {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: linear-gradient(to right, #667eea 0%, #764ba2 100%);
  outline: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}
input[type="range"]:hover {
  opacity: 1;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102,126,234,0.5);
  border: 3px solid #667eea;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102,126,234,0.5);
  border: 3px solid #667eea;
}

/* Toggle switch for checkboxes */
.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  cursor: pointer;
}
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  background: #d1d5db;
  border-radius: 13px;
  transition: background 0.3s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch-wrapper input[type="checkbox"]:checked + .toggle-switch {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.toggle-switch-wrapper input[type="checkbox"]:checked + .toggle-switch::after {
  transform: translateX(24px);
}
.toggle-switch-label {
  font-weight: 600;
  font-size: 14px;
}

/* Small inline toggle for true/false */
.inline-toggle-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.inline-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  transition: background 0.3s;
  flex-shrink: 0;
  cursor: pointer;
}
.inline-toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  pointer-events: none;
}
.inline-toggle-wrapper input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.inline-toggle-wrapper input[type="checkbox"]:checked + .inline-toggle {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.inline-toggle-wrapper input[type="checkbox"]:checked + .inline-toggle::after {
  transform: translateX(20px);
}
.inline-toggle-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

/* Segmented control for radio buttons - Carved style */
.segmented-control {
  display: flex;
  background: #d1d5db;
  border-radius: 12px;
  padding: 6px;
  margin: 1rem 0;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.segmented-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.segmented-option {
  flex: 1;
  text-align: center;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 14px;
  color: #6b7280;
  position: relative;
  z-index: 1;
  background: transparent;
}
.segmented-control input[type="radio"]:checked + .segmented-option {
  background: #fff;
  color: #60a5fa;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
  transform: scale(1.02);
}
.segmented-option:hover {
  color: #374151;
}
.segmented-control input[type="radio"]:checked + .segmented-option:hover {
  color: #60a5fa;
}

/* Multi-option segmented control */
.segmented-control-multi {
  display: flex;
  background: #d1d5db;
  border-radius: 12px;
  padding: 6px;
  margin: 1rem 0;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.segmented-control-multi input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.segmented-option-multi {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  font-size: 13px;
  color: #6b7280;
  position: relative;
  z-index: 1;
  background: transparent;
}
.segmented-control-multi input[type="radio"]:checked + .segmented-option-multi {
  background: #fff;
  color: #60a5fa;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
  transform: scale(1.02);
}
.segmented-option-multi:hover {
  color: #374151;
}
.segmented-control-multi input[type="radio"]:checked + .segmented-option-multi:hover {
  color: #60a5fa;
}

@media (max-width: 768px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-content { padding: 1.5rem; }
  .header { padding: 2rem 1.5rem; }
}