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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #2c3e50;
}

.app-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.data-entry,
.preview {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 20px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 5px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #555;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.company-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.company-info h3 {
  margin-bottom: 10px;
  color: #2c3e50;
}

.company-info p {
  margin: 5px 0;
  color: #666;
}

.items-section {
  margin-top: 20px;
}

.items-header {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 1fr auto;
  gap: 10px;
  font-weight: 600;
  padding: 10px 0;
  border-bottom: 2px solid #3498db;
  margin-bottom: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.item-row input {
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
}

.item-total {
  text-align: right;
  font-weight: 500;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
  padding: 4px 8px;
  font-size: 12px;
}

.btn-danger:hover {
  background-color: #c0392b;
}

.add-item-btn {
  margin: 15px 0;
}

.totals {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #3498db;
}

.total-row {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
  padding: 5px 0;
}

.total-row.final {
  font-weight: 600;
  font-size: 1.1em;
  border-top: 1px solid #ddd;
  padding-top: 10px;
  margin-top: 10px;
}

.preview {
  min-height: 400px;
}

.preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: #f8f9fa;
  border: 2px dashed #ddd;
  border-radius: 4px;
  color: #999;
  font-style: italic;
}

.preview-image {
  max-width: 100%;
  height: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-actions {
  margin-top: 15px;
  text-align: center;
}

.btn-success {
  background-color: #27ae60;
  color: white;
  padding: 10px 20px;
}

.btn-success:hover {
  background-color: #229954;
}

@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .app-layout {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .items-header,
  .item-row {
    grid-template-columns: 2fr 80px 80px 80px auto;
    gap: 5px;
    font-size: 13px;
  }

  .item-row input {
    padding: 4px 6px;
    font-size: 12px;
  }

  .form-group input {
    padding: 10px 12px;
  }

  h1 {
    font-size: 1.5em;
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  .items-header,
  .item-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .item-row {
    background: #f8f9fa;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: none;
  }

  .items-header {
    display: none;
  }

  .item-row input {
    margin-bottom: 5px;
  }

  .item-total {
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
  }
}

.templates-selector {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1rem;

  & > * {
    height: 2rem;
  }

  #templates {
    width: 100%;
  }
}
