* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

/* Header */
.header {
  background: linear-gradient(135deg, #5e72e4 0%, #825ee4 100%);
  color: #fff;
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: #5e72e4;
  color: #fff;
}

.btn-primary:hover {
  background: #4c63d2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(94, 114, 228, 0.4);
}

.btn-secondary {
  background: #fff;
  color: #5e72e4;
  border: 1px solid #5e72e4;
}

.btn-secondary:hover {
  background: #f0f2ff;
}

.btn-success {
  background: #2dce89;
  color: #fff;
}

.btn-success:hover {
  background: #24a46d;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
  margin-bottom: 10px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  color: #f5365c;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  line-height: 1;
}

/* Sections */
.section {
  padding: 24px 32px;
  border-bottom: 1px solid #e9ecef;
}

.customer-section {
  background: #f8f9fe;
}

.form-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-group label {
  font-weight: 600;
  color: #525f7f;
  min-width: 80px;
}

.form-group input[type="text"],
.form-group textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 14px;
  min-width: 250px;
}

.form-group textarea {
  min-width: 100%;
  resize: vertical;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #5e72e4;
  box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.1);
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge-warning {
  background: #fb6340;
  color: #fff;
}

/* Upload Area */
.upload-section {
  padding: 40px 32px;
}

.upload-area {
  border: 3px dashed #dee2e6;
  border-radius: 12px;
  padding: 60px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-area:hover {
  border-color: #5e72e4;
  background: #f8f9fe;
}

.upload-icon {
  width: 64px;
  height: 64px;
  fill: #5e72e4;
  margin-bottom: 16px;
}

.upload-hint {
  color: #8898aa;
  font-size: 13px;
  margin-top: 8px;
}

.loading {
  text-align: center;
  padding: 30px;
  color: #525f7f;
}

.spinner {
  border: 4px solid #f3f4f6;
  border-top: 4px solid #5e72e4;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Main Workspace */
.main-workspace {
  padding: 0;
}

.workspace-container {
  display: flex;
  height: calc(100vh - 200px);
  min-height: 600px;
}

/* Fields Panel */
.fields-panel {
  width: 320px;
  border-right: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  background: #f8f9fe;
}

.fields-panel h3 {
  padding: 16px 20px;
  background: #5e72e4;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.fields-panel h4 {
  padding: 8px 20px;
  font-size: 13px;
  color: #525f7f;
  background: #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-categories {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
}

.field-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid #e9ecef;
}

.field-item:hover {
  background: #fff;
}

.field-item.field-active {
  background: #e3e8ff;
}

.field-item.field-marked {
  background: #d4edda;
}

.field-checkbox {
  font-size: 18px;
  width: 20px;
}

.field-name {
  font-weight: 500;
  color: #32325d;
}

.field-key {
  font-size: 11px;
  color: #8898aa;
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.field-page {
  font-size: 11px;
  color: #fff;
  background: #5e72e4;
  padding: 2px 6px;
  border-radius: 4px;
}

.panel-actions {
  padding: 16px 20px;
  border-top: 2px solid #e9ecef;
  background: #fff;
}

/* PDF Panel */
.pdf-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.pdf-controls {
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: #f8f9fe;
  border-bottom: 1px solid #e9ecef;
}

.page-info {
  font-weight: 600;
  color: #32325d;
  min-width: 120px;
  text-align: center;
}

.pdf-viewer {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  background: #f0f2f5;
}

.pdf-canvas,
.draw-canvas {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pdf-canvas {
  z-index: 1;
}

.draw-canvas {
  z-index: 2;
  cursor: crosshair;
}

.marking-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(94, 114, 228, 0.95);
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  z-index: 10;
}

.marking-hint p {
  margin: 0;
  line-height: 1.6;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-bottom: 24px;
  color: #32325d;
  font-size: 20px;
}

.modal-content .form-group {
  margin-bottom: 20px;
  display: block;
}

.modal-content .form-group label {
  display: block;
  margin-bottom: 8px;
  min-width: auto;
}

.modal-content .form-group p {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Responsive */
@media (max-width: 1024px) {
  .workspace-container {
    flex-direction: column;
    height: auto;
  }
  
  .fields-panel {
    width: 100%;
    max-height: 300px;
  }
  
  .pdf-panel {
    height: 500px;
  }
}
