* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
}

h1 {
  color: #ffffff;
  text-align: center;
  margin-bottom: 30px;
  font-size: 2.5em;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h2 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.4em;
}

/* Upload Section */
.upload-section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.printer-selection {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 8px;
  border-left: 4px solid #ff6b35;
  flex-wrap: wrap;
}

.printer-selection label {
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

#printerProfile {
  flex: 1;
  min-width: 200px;
  padding: 10px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  background: white;
  transition: border-color 0.3s;
}

#printerProfile:hover {
  border-color: #ff6b35;
}

#printerProfile:focus {
  outline: none;
  border-color: #ff6b35;
}

.bed-info {
  padding: 8px 15px;
  background: white;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #666;
  border: 1px solid #e0e0e0;
  white-space: nowrap;
}

.file-upload {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

#fileInput {
  flex: 1;
  min-width: 250px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.3s;
}

#fileInput:hover {
  border-color: #ff6b35;
}

#fileInput:focus {
  outline: none;
  border-color: #ff6b35;
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 6px rgba(247, 147, 30, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(247, 147, 30, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Viewer Section */
.viewer-section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Settings Section */
.settings-section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.preset-btn {
  padding: 12px 20px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
  color: #333;
}

.preset-btn:hover {
  border-color: #ff6b35;
  background: #fff5f2;
  transform: translateY(-2px);
}

.preset-btn.preset-active {
  border-color: #ff6b35;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: white;
  box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
}

.settings-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  color: #ff6b35;
  background: #fff5f2;
}

.tab-btn.active {
  color: #ff6b35;
  border-bottom-color: #ff6b35;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.setting-group {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #ff6b35;
}

.setting-group h3 {
  color: #333;
  font-size: 16px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.setting-item {
  margin-bottom: 15px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.setting-item label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.setting-item select,
.setting-item input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  transition: border-color 0.3s;
}

.setting-item select:focus,
.setting-item input[type="number"]:focus {
  outline: none;
  border-color: #ff6b35;
}

.setting-item input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff6b35;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.setting-item input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff6b35;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-unit select,
.input-with-unit input {
  flex: 1;
}

.unit {
  font-size: 12px;
  color: #999;
  font-weight: 600;
  min-width: 40px;
}

.support-options {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #ddd;
}

.estimate-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  border-radius: 8px;
  border-left: 4px solid #4caf50;
}

.estimate-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.estimate-label {
  font-size: 12px;
  color: #666;
  font-weight: 600;
}

.estimate-value {
  font-size: 18px;
  color: #333;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.slice-action {
  margin-top: 20px;
  text-align: center;
}

.btn-slice {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  color: white;
  border: none;
  padding: 16px 40px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
}

.btn-slice:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(76, 175, 80, 0.4);
}

.btn-slice:active {
  transform: translateY(-1px);
}

/* Tools Panel */
.tools-panel {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.tool-group {
  background: white;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #ff6b35;
}

.tool-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
  font-size: 14px;
}

.tool-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tool-buttons button {
  background: #f0f0f0;
  border: 1px solid #ddd;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  color: #333;
}

.tool-buttons button:hover {
  background: #ff6b35;
  color: white;
  border-color: #ff6b35;
  transform: translateY(-1px);
}

.tool-buttons button:active {
  transform: translateY(0);
}

.btn-reset {
  background: #e74c3c !important;
  color: white !important;
  border-color: #e74c3c !important;
}

.btn-reset:hover {
  background: #c0392b !important;
  border-color: #c0392b !important;
}

.btn-apply {
  background: #3498db !important;
  color: white !important;
  border-color: #3498db !important;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid;
  transition: all 0.2s;
}

.btn-apply:hover {
  background: #2980b9 !important;
  border-color: #2980b9 !important;
}

#scaleInput {
  width: 80px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

#scaleInput:focus {
  outline: none;
  border-color: #ff6b35;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  background: #f0f0f0;
  border-radius: 6px;
  transition: background 0.2s;
  font-size: 13px;
}

.checkbox-label:hover {
  background: #e0e0e0;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

#viewer {
  width: 100%;
  height: 700px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: #2a2a2a;
}

#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#loading-overlay.hidden {
  display: none;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #ff6b35;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#loading-overlay p {
  color: white;
  font-size: 16px;
}

.viewer-info {
  margin-top: 15px;
  padding: 12px;
  background: #f5f5f5;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #555;
  min-height: 40px;
  line-height: 1.6;
}

/* Jobs Section */
.jobs-section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#jobs {
  list-style: none;
}

.job-item {
  padding: 15px;
  margin-bottom: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  border-left: 4px solid #ddd;
  transition: all 0.3s;
}

.job-item:hover {
  background: #f0f0f0;
  transform: translateX(5px);
}

.job-done {
  border-left-color: #4caf50;
}

.job-running {
  border-left-color: #ff9800;
}

.job-failed {
  border-left-color: #f44336;
}

.job-status {
  margin-right: 8px;
  font-size: 18px;
}

.download-link {
  margin-left: 15px;
  color: #ff6b35;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s;
}

.download-link:hover {
  color: #f7931e;
  text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .tools-panel {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 1.8em;
  }

  .printer-selection {
    flex-direction: column;
    align-items: stretch;
  }

  #printerProfile {
    width: 100%;
  }

  .bed-info {
    text-align: center;
  }

  .file-upload {
    flex-direction: column;
  }

  #fileInput {
    width: 100%;
  }

  .btn-primary {
    width: 100%;
  }

  .preset-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .settings-tabs {
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .estimate-info {
    grid-template-columns: 1fr;
  }

  .btn-slice {
    width: 100%;
    font-size: 16px;
  }

  .tools-panel {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  #viewer {
    height: 500px;
  }

  .viewer-info {
    font-size: 10px;
  }

  .tool-buttons {
    gap: 6px;
  }

  .tool-buttons button {
    font-size: 12px;
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .upload-section,
  .viewer-section,
  .jobs-section {
    padding: 15px;
  }

  #viewer {
    height: 400px;
  }

  .tools-panel {
    padding: 15px;
  }

  .tool-group {
    padding: 12px;
  }
}