* {
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #fff5e6 0%, #ffe8cc 100%);
  color: #5c3d2e;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.05"><path d="M20,50 Q50,20 80,50 Q50,80 20,50 Z" fill="%235c3d2e"/></svg>');
  min-height: 100vh;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px;
}

.header {
  text-align: center;
  padding: 20px 0 10px;
  border-bottom: 2px dashed #d4a574;
  margin-bottom: 20px;
}
.header h1 {
  margin: 0;
  color: #8b4513;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}
.header p {
  color: #a0522d;
  margin-top: 5px;
  font-style: italic;
}

.tabs {
  display: flex;
  background: #fffaf0;
  border-radius: 12px 12px 0 0;
  overflow-x: auto;
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
  border: 1px solid #e6ccb2;
  border-bottom: none;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  color: #a0522d;
  white-space: nowrap;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
  border-right: 1px solid #f0e6d6;
}
.tab-btn:last-child {
  border-right: none;
}
.tab-btn:hover {
  background: #fff5e6;
  color: #8b4513;
}
.tab-btn.active {
  color: #d2691e;
  background: #fff;
  border-bottom: 3px solid #d2691e;
}

.tab-content {
  display: none;
  padding: 24px;
  background: white;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 6px 20px rgba(139, 69, 19, 0.1);
  border: 1px solid #e6ccb2;
  border-top: none;
  margin-bottom: 30px;
}
.tab-content.active {
  display: block;
}

.section-title {
  color: #8b4513;
  border-left: 4px solid #d4a574;
  padding-left: 12px;
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 22px;
}

label {
  display: inline-block;
  font-weight: 600;
  margin: 6px 0;
  color: #5c3d2e;
}
input, select {
  padding: 8px 12px;
  margin: 6px 7px 0 0;
  border: 1px solid #d4a574;
  border-radius: 8px;
  font-size: 15px;
  background: #fffaf0;
  color: #5c3d2e;
  transition: border 0.3s;
}
input:focus, select:focus {
  outline: none;
  border-color: #d2691e;
  box-shadow: 0 0 0 2px rgba(210, 105, 30, 0.2);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  margin-bottom: 7px;
  padding: 12px;
  background: #fffaf0;
  border-radius: 10px;
  border: 1px solid #e6ccb2;
  transition: transform 0.2s;
}
.row:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(139, 69, 19, 0.1);
}

.row .input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.row select {
  min-width: 200px;
  flex-grow: 1;
}

.row input[type="number"] {
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

.unit-label {
  background: #e6ccb2;
  border: 1px solid #d4a574;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: monospace;
  font-size: 14px;
  white-space: nowrap;
  color: #5c3d2e;
  font-weight: 600;
  flex-shrink: 0;
}

.row button {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .row select {
    min-width: 100%;
    width: 100%;
    margin: 0;
  }
  
  .row .input-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
  }
  
  .row input[type="number"] {
    width: 100%;
    margin: 0;
  }
  
  .row button {
    width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px;
  }
}

#result {
  margin-top: 25px;
  background: #fffaf0;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #d4a574;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  color: #5c3d2e;
  box-shadow: inset 0 2px 4px rgba(139, 69, 19, 0.05);
}

#copyIcon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #d4a574;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: all 0.2s;
  color: white;
}
#copyIcon:hover {
  opacity: 1;
  background: #d2691e;
  transform: scale(1.05);
}

.product-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 14px;
  background: linear-gradient(to right, #fffaf0, #fff5e6);
  border-radius: 10px;
  border: 1px solid #e6ccb2;
  flex-wrap: wrap;
  gap: 10px;
  transition: all 0.2s;
}
.product-item:hover {
  border-color: #d4a574;
  box-shadow: 0 4px 8px rgba(139, 69, 19, 0.1);
}
.product-item > span {
  flex: 1;
  min-width: 140px;
  font-size: 15px;
  color: #5c3d2e;
}
.product-item button {
  flex-shrink: 0;
  margin: 0 4px;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
}

.edit-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  padding: 10px;
  background: #fff;
  border-radius: 8px;
  border: 1px dashed #d4a574;
}
.edit-form input, .edit-form select {
  margin: 0;
}

button {
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid #d4a574;
  border-radius: 8px;
  background: linear-gradient(to bottom, #fffaf0, #f8e5c8);
  font-size: 15px;
  font-weight: 600;
  color: #8b4513;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s;
}
button:hover {
  background: linear-gradient(to bottom, #f8e5c8, #f0d4a8);
  border-color: #d2691e;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(139, 69, 19, 0.2);
}
button:active {
  transform: translateY(0);
}

.calc-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.product-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.basic-info-section {
  background: #fffaf0;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #e6ccb2;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.nutrition-section {
  background: #fffaf0;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #e6ccb2;
  height: 100%;
  display: flex;
  flex-direction: column;
}

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

.form-field label {
  display: block;
  width: 100%;
  margin-bottom: 5px;
  font-weight: 600;
  color: #5c3d2e;
}

.form-field input,
.form-field select {
  width: 100%;
  margin: 0;
}

.pack-unit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.pack-unit-row .form-field {
  margin-bottom: 0;
}

.nutrition-grid-new {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 12px;
  margin-top: 15px;
  flex-grow: 1;
}

.nutrition-item:nth-child(1),
.nutrition-item:nth-child(2) {
  grid-row: 1;
}

.nutrition-item:nth-child(3),
.nutrition-item:nth-child(4) {
  grid-row: 2;
}

.nutrition-item {
  text-align: center;
  padding: 15px 10px;
  background: white;
  border-radius: 8px;
  border: 1px solid #d4a574;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.nutrition-label {
  font-size: 14px;
  color: #8b4513;
  text-align: left;
  width: 100%;
}

.nutrition-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #d4a574;
  border-radius: 6px;
  text-align: left;
  font-size: 15px;
  background: #fffaf0;
  color: #5c3d2e;
}

.nutrition-input:focus {
  outline: none;
  border-color: #d2691e;
  box-shadow: 0 0 0 2px rgba(210, 105, 30, 0.2);
}

.add-product-btn {
  width: 100%;
  justify-content: center;
  grid-column: 1 / -1;
}

.footer {
  text-align: center;
  padding: 20px;
  margin-top: 30px;
  color: #a0522d;
  font-size: 14px;
  border-top: 1px dashed #d4a574;
}

@media (max-width: 768px) {
  .product-form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .pack-unit-row {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .nutrition-grid-new {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0 10px;
  }
  .header h1 {
    font-size: 24px;
  }
  .tabs {
    padding: 0;
  }
  .tab-btn {
    padding: 12px 14px;
    font-size: 14px;
  }
  .tab-content {
    padding: 16px;
  }
  .section-title {
    font-size: 18px;
  }
  label {
    font-size: 14px;
  }
  input[type="text"], input[type="number"], select {
    font-size: 14px;
    padding: 7px;
    margin-right: 5px;
  }
  .row select {
    min-width: 100%;
    font-size: 14px;
  }
  .row input[type="number"] {
    width: 100%;
    font-size: 14px;
    padding: 6px 8px;
  }
  .product-item {
    padding: 10px;
  }
  .product-item > span {
    font-size: 14px;
  }
  #result {
    font-size: 14px;
    padding: 16px;
  }
  #copyIcon {
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    font-size: 13px;
  }
  .product-item button {
    font-size: 13px;
    padding: 5px 10px;
  }
  .calc-actions button {
    font-size: 14px;
    padding: 8px 14px;
  }
  .nutrition-item {
    min-height: 70px;
    padding: 12px 10px;
  }
  .unit-label {
    padding: 5px 10px;
    font-size: 13px;
  }
}

#newProductName {
  width: 100% !important;
}